getting CAN Message ID with S12XF512

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

getting CAN Message ID with S12XF512

跳至解决方案
2,023 次查看
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

标签 (1)
0 项奖励
回复
1 解答
712 次查看
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 项奖励
回复
5 回复数
712 次查看
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 项奖励
回复
712 次查看
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 项奖励
回复
713 次查看
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 项奖励
回复
712 次查看
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 项奖励
回复
712 次查看
kef
Specialist I
:smileyhappy: . Good Luck
0 项奖励
回复