CAN Transmission Issue - interrupt based

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

CAN Transmission Issue - interrupt based

ソリューションへジャンプ
1,773件の閲覧回数
freescale_satya
Contributor III

Hi,

 

I am trying to transmit around 10 CAN messages at a single instance. here is the logic iam using for S12x micro

 

#define NO_OF_TX_MESSAGES   10

for(index = 0; index < NO_OF_TX_MESSAGES; index++)
{
  //copy id's
 //copy datalength
 //copy all databytes from application buffer
 
 if(TFLG)
 {
   buf_sel = TFLG;
   TBSEL = buf_sel;
 }
 
 // form the correct idrs
 // fill the data into data segment registers
 
 buf_sel = TBSEL;
 TIER |= 0x07; // enable interrupts
 
 TFLG =  buf_sel; // transmit the frame
}


canInterrupt(void)
{
 if(TFLG)
  TIER = 0x00;
}

 

1. Could somebody tell me if the logic is correct or can i make any improvements?

2. I always find not more than 3 messages being transmitted at a time

ex: i want to transmit 0x400, 0x401, 0x402, 0x403 ... 0x409 messages i find only 0x400, 0x401, 0x402 messages are only being transmitted. when i go through the data sheet it says 3 transmit buffers is this issue related to this.

could somebody help me on this? i am unable to proceed further without resolving this issue.

 

Please let me know if u did not understand or i missed something.

 

thanks in advance,

 

regards,

satya

ラベル(1)
0 件の賞賛
返信
1 解決策
1,227件の閲覧回数
freescale_satya
Contributor III

Hi kef,

 

I was able to resolve the issue for the interupt based as well. thankyou for the suggestions.

 

regards,

satya

元の投稿で解決策を見る

0 件の賞賛
返信
3 返答(返信)
1,227件の閲覧回数
kef
Specialist I

Logic is wrong. After 3 Tx buffers are filled and scheduled, CANTFLG will be 0 until one of messages is transferred. Now look at your pseudocode and answer yourself what will happen then? Since your are not waiting  while( !CANTFLG){}, remaining 7 messages will be ignored.

Another bug in your pseudocode is that you select TX buffer after copying data to TX buffer. You need first to write CANTBSEL=CANTFLG, and then fill TX buffer.

It is not clear what for you are enabling transmit interrupt and why every time for all 3 TX buffers.

0 件の賞賛
返信
1,227件の閲覧回数
freescale_satya
Contributor III

Hi kef,

 

Thankyou very much for the reply. i could get some progress by solving the issue for polling basis but still iam facing some issues with interrupt based. i am trying i will give myself one more day before i update you.

 

thanks again,

 

regards,

satya

0 件の賞賛
返信
1,228件の閲覧回数
freescale_satya
Contributor III

Hi kef,

 

I was able to resolve the issue for the interupt based as well. thankyou for the suggestions.

 

regards,

satya

0 件の賞賛
返信