How to set CAN AMR/ACR registers to accept "unaligned" ranges

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
DaVa_2285651
Level 3
Level 3
10 questions asked First solution authored 10 sign-ins

The mailboxes in the CAN devices in the PSoC 4 series have an Acceptance Mask Register and an Acceptance Code Register that can be set so the mailbox will receive a range of IDs.  This is explained here:

   

http://www.cypress.com/knowledge-base-article/acceptance-filter-implementation-can-receive-message-k...

   

The register values for the example range (0x100 to 0x1FF) make sense.  However, I can't seem to determine how to set the registers for an ID range like 0x002 to 0x0FE.  To make sure the mailbox only accepts messages with ID >= 0x02, I would want to set the AMR to check the least significant bit of the ID, and set the least significant bit of the ID in the ACR to 0.  But there are IDs in the range 0x02 to 0xFE where the least significant bit is not 0, such as 0x03.  So if I then set the AMR not to check the least significant bit of the ID, or set the least significant bit of the ID in the ACR register to 1, then the mailbox will accept ID 0x01, which is outside of my desired range.

   

It seems as though all bits in the maximum range value and minimum range value have to be opposite except for the most significant, otherwise the AMR and ACR cannot be set to accept the range.  Am I understanding this correctly?  Is there a way to set an ID range like 0x02 to 0xFE?

0 Likes
1 Reply
Anonymous
Not applicable

Based on reading the post you linked, it seems that you are indeed understanding it correctly. The Mask essentially only bit checks the portion of the ID set to 0's, which is then compared with the ACR which can have 0,1, or don't care for the code. You will be able to do a pseudo range, like only counting even numbers, or only counting values divisible by 3,4, etc. But I don't think you can do a range from 0x002 to 0x0FE without discluding some of the ID codes.

   

For example, consider if the mask and codes were all restricted to 4 bits:

   

Setting the mask to 1100 would check bits 0, and 1 of the codes. Then, you could set the ACR to:

   

xxxx = Receive all messages

   

xxx0 = Receive 0000,0010,0100,0110,1000,1010,1100,1110, but no others

   

xx00 = Receive 0000,0100,1000,1100, but no others

   

xx10 = Receive 0010,0110,1010,1110, but no others

   

Using just the ACR and AMR feature I don't see a way to do a range like the one you are suggesting. The mask allows you to set a range of devices, but doesn't give you many options for the numbers within that range.

0 Likes