getting CAN Message ID with S12XF512

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

getting CAN Message ID with S12XF512

Jump to solution
2,070 Views
eCARus
Contributor I

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

Labels (1)
0 Kudos
Reply
1 Solution
759 Views
kef
Specialist I

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?

 

View solution in original post

0 Kudos
Reply
5 Replies
759 Views
kef
Specialist I

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.

 

 

 

0 Kudos
Reply
759 Views
eCARus
Contributor I

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

 

interrupts.c

CAN_driver.c

Message Edited by t.dowe on 2009-09-14 11:25 AM
0 Kudos
Reply
760 Views
kef
Specialist I

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?

 

0 Kudos
Reply
759 Views
eCARus
Contributor I

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

0 Kudos
Reply
759 Views
kef
Specialist I
:smileyhappy: . Good Luck
0 Kudos
Reply