CAN Transmission Issue - interrupt based

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

CAN Transmission Issue - interrupt based

跳至解决方案
979 次查看
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 解答
433 次查看
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 回复数
433 次查看
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 项奖励
回复
433 次查看
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 项奖励
回复
434 次查看
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 项奖励
回复