Hello! I'm writing software for test equipment and have to handle a lot of different CAN messages. (Controller: Infineon C167CR, Phytec Board, uVision 2) So I used the message objects 1 - 14 for message sending and want now use the last message object for receiving different messages. It seem's to work, so I got an interrupt and an message on a LCD display, also connected to the controller, but I have problems extracting the message ID of the received message. I use the arbitration register of message object 15 and try to extract out the ID with the following code: (The layout of the arbitration register is described in chapter 18 of the C167 User's Manual by Infineon, I use standard CAN - 11 Bit IDs!)
RCV_ID = CAN_MSGOBJ[15].arbitr; RCV_ID = (RCV_ID & 0xE0FF0000) >>13; temp = (RCV_ID >> 16) & 0x00000007; RCV_ID = (RCV_ID | temp) & 0x000007FF;
In that case, you'll have to dig deeper. Check the generated assembly, watch the value of all variables as you single-step through this. Are you sure the mapping of the chip's two 16-bit registers that comprise the 32 CAN arbitration register are mapped correctly into the single, assumedly 32-bit datafiled "arbitr" of your message object struct? Looking at the Chip docs, there seems to be a rather peculiar mixup of byte orders. The CAN controller core is of the usual Intel 82527-alike kind, which has big-endian byte order. The C16x OTOH has little-endian inside each 16-bit, but the word order is still big-endian. This looks like a rather sure recipe for desaster.
Hello! Thanks for the hints, I'll check it! Have a nice day! SVEN