Hi,
i want to extract the ID of an incoming CAN message inside an ISR. I'm able to send and recieve messages, extract the message data, and send messages with own ID's. The MSCAN identifier Acceptance Filters get the right ID hits, but when i read out the Identifier Registers (IDR 0- 3) i get 0x000 after a reset. If I sent a message before receiving, the message ID of the sent message is still in the IDR registers.
But how do I get the message ID of the incoming message?
Any hints would be greatly appreciated, as I didn't find any example code on the internet.
Chris
Solved! Go to Solution.
In vfnCAN_ReceivedFrame(). you have this:
*id=CAN0TXIDR0<<3;
*id|=CAN0TXIDR1>>5;
You are trying to read TX IDRs here, not RX. Is problem solved?
Inside your CANRX ISR, are you clearing RXF flag before reading CANRXIDR* registers or after? RXF must be cleared only after you finished reading all important data from RX buffer. RX buffer is paged and one of 5 message buffers is readable only while RXF flag is set. Clearing RXF removes current full RX buffer from the memory map.
TX buffer is also paged, but visibility of specific TX buffer in the memory map is manually controlled using CANTBSEL register. That's why you may see CANTXIDR of last sent message.
Hi kef,
thanks for the fast reply. I took a Freescale code example and modified it. The clearing of the RXF is the last statement before return, so i read the IDR's and DSR' before i clear the flag. I'm wondering why the RX buffer isn't overwritten by the new incoming message ID.
I attached the two important c files which include the CANRxisr and the vfnCAN_ReceivedFrame().
Perhaps you could give me a short code example how to read out the ID if the way i'm doing it in the code is wrong.
thanks so far for your help,
Chris
In vfnCAN_ReceivedFrame(). you have this:
*id=CAN0TXIDR0<<3;
*id|=CAN0TXIDR1>>5;
You are trying to read TX IDRs here, not RX. Is problem solved?
Hey kef,
big thanks from all the eCARus Team and especially from me, i tried to find the bug since last wednesday.
thanks a lot and take care
Chris