getting CAN Message ID with S12XF512

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

getting CAN Message ID with S12XF512

ソリューションへジャンプ
2,076件の閲覧回数
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 解決策
765件の閲覧回数
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 返答(返信)
765件の閲覧回数
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 件の賞賛
返信
765件の閲覧回数
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 件の賞賛
返信
766件の閲覧回数
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 件の賞賛
返信
765件の閲覧回数
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 件の賞賛
返信
765件の閲覧回数
kef
Specialist I
:smileyhappy: . Good Luck
0 件の賞賛
返信