When using CAN with mixed standard and extended IDs, how do I set the mask register?I wish to receive Standard ID messages from 0 to 15.
So I set the mask to 0x1FC3FFFF, which should mask all bits apart from bits 0-3 of the SID
However, the mailbox is also accepting Extended ID messages with the correct bits in the SID field, but with ANY bits in the EID field as if it were not masked at all.
A bit in the Mask register masks the associated ID bit when it is 0. When it is 1, it is not masking:
So a value of 0x1FC3FFFF in the Mask Register will mask bits 0-3 of the SID and will not accept anything else. All EIDs will be accepted.
The manual says:
“When an SID[10:0] bit is set to 0, the respective received ID is not compared with the associated mailbox ID bit. When an SID[10:0] bit is set to 1, the respective received ID bit is compared with the associated mailbox ID bit.“
so a zero lets any value through, and a 1 only allows the data through if it matches.
So everything must match apart from bits 0-3 of the SID.
All the EID bits are zero, and the EID bits in the mask are all 1, so a comparison should take place, and it should be rejected if the EID bits in the message are non-zero.
Is that not correct?
Yes, your understanding is correct, I was wrong.
What is the IDE bit of the Maiblox register ?
The receive mailbox receives only the ID format specified in the IDE bit. The IDE bit is enabled when the IDFM bits in CTLR are 10b (mixed ID mode)
It was zero (standard length data), but it only receives extended data.
When the whole system was standard length data, it was fine, but with a mixed system only those mailboxes with the Invalid mask register bit set work properly.
What is the value of MKIVLR register ?
In Mailbox register, do you have IDE = 0 and getting a EID ?
Not sure how this is possible, becuase EID bits are undefined when IDE = 0.
The relevant bit in MKIVLR is zero.
When an extended message arrives that matches the relevant SID bits its ID is loaded into the EID bits.
I've given up and gone home now, I'll have another look tomorrow morning.
I have to conclude that the masking and filtering simply does not work on mixed standard and extended messages.
Do you suggest that the receive mailbox is accepting both Standard and Extended ID's at the same time ?
Not absolutely sure, but it seems to be accepting only extended IDs. The other end of the wire is, as far as I know, sending standard IDs, but none is being received
That being said and with IDE bit = 0, do you see EID bits set in the mailbox register ?