Receive data uninterruptedly from a CAN module

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

Receive data uninterruptedly from a CAN module

864件の閲覧回数
shiyinbiao
Contributor II

How can I use a CAN module to receive ten frame data uninterruptedly.Because when I send data to MPC5606B, I can only received two frame data at the most.My code based on MPC5606B as follows:

 

void RecieveMsg (void)
{
   uint8_t j;
   vuint32_t dummy;
   vuint32_t RxID=0;
   if(CAN_0.IFRL.B.BUF04I == 1)
    {
         RxCODE = CAN_0.BUF[4].CS.B.CODE; 
         RxID = CAN_0.BUF[4].ID.R;
         RxLENGTH = CAN_0.BUF[4].CS.B.LENGTH;
         for (j=0; j<RxLENGTH; j++)
         {
            RxDATA[j] = CAN_0.BUF[4].DATA.B[j];
            printf("RxDATA :%x\r",(uint16_t)RxDATA[j]);/*Via a serial port to print data to screen*/
         }
         RxTIMESTAMP = CAN_0.BUF[4].CS.B.TIMESTAMP;
         dummy = CAN_0.TIMER.R; 
         CAN_0.IFRL.R = 0x00000010; 
    }

}

ラベル(1)
2 返答(返信)

773件の閲覧回数
martin_kovar
NXP Employee
NXP Employee

Hi,

I checked your code and the problem is most probably in function printf. Calling this function has huge overhead and during the printing message via UART, CAN messages get lost except the first one you receive and the last one, which stays in SMB.

There are few ways, how to solve this problem.

The simplest one is to configure individual masking and initialize 10 message buffers.

Second way is to create buffer in RAM memory and send data from this buffer outside the FlexCAN interrupt.

Regards,

Martin

773件の閲覧回数
shiyinbiao
Contributor II

Thank you very much.

0 件の賞賛
返信