NXP S12ZVC MSCAN FIFO question

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

NXP S12ZVC MSCAN FIFO question

1,463 次查看
kentseng
Contributor II

Hi all

         I follow (AN4975_SW) demo code from NXP , I use  interrupt to receive CAN bus data,

but now i have a question , when i through CAN bus tools ( a CAN bus tool ) to send date,

when i send one data packet , S12ZVC get the data packet , but I can't through read some

register from S12ZVC , but I send five data packets , I can read date from register

( like...CAN0RXDSR0...etc) , but i think it strange , so maybe having some way , but i don't

know ,  someone help ,thanks.

0 项奖励
6 回复数

936 次查看
hbch
Contributor III

Hi,

I can only read the desired message after five times transmission. Is there any solution to get the message immediate after  transmission?

best regrads,

Guoqiang Yang

0 项奖励

936 次查看
lama
NXP TechSupport
NXP TechSupport

Hi,

I would like only to ask whether you have already solved the issue or it still exists.

If you solved it, please, share the solution.

Otherwise, have you checked by scope what you send to the MCU? The CAN issues can be anywhere. I usually start with loop-back communication to be sure the MCU and my routines are correctly working. Then, if possible, I add communication between two nodes at the same MCU without transceiver. And finally, with transceiver. Of course, I start without interrupt mode to exclude additional issues. It is easier to localized he mistake in this way. But this is only my approach.

Such an example is attached...and it is very similar to the SW you use.

best regrads,

Ladislav

0 项奖励

936 次查看
kentseng
Contributor II

Hi,

This issue is currently unresolved, so you are recommended not to use interrupt reception to debug??

best regrads

0 项奖励

936 次查看
hbch
Contributor III

Hi,

I use polling mode, here is my code:

u8 CAN_RxMsg(void)
{
  u8 Status = CAN0CTL0_RXFRM;
 
  if(CAN0CTL0_RXFRM)
  {
    CAN0CTL0_RXFRM = 1;
    CAN0RFLG=0xC3;             /*clear flag*/

    CanRxMsg.Data[0] = CAN0RXDSR0;/*CAN rx message handle*/
    CanRxMsg.Data[1] = CAN0RXDSR1;
    CanRxMsg.Data[2] = CAN0RXDSR2;
    CanRxMsg.Data[3] = CAN0RXDSR3;
    CanRxMsg.Data[4] = CAN0RXDSR4;
    CanRxMsg.Data[5] = CAN0RXDSR5;
    CanRxMsg.Data[6] = CAN0RXDSR6;
    CanRxMsg.Data[7] = CAN0RXDSR7;
    
    if(EXTENDED_MSG==CAN0RXIDR1_IDE)      
    {
      CanRxMsg.ID = ((u32)CAN0RXIDR0)<<21;
      CanRxMsg.ID |= ((u32)CAN0RXIDR1&0xe0)<<13;
      CanRxMsg.ID |= ((u32)CAN0RXIDR1&0x07)<<15;
      CanRxMsg.ID |= ((u32)CAN0RXIDR2)<<7;
      CanRxMsg.ID |= ((u32)CAN0RXIDR3)>>1;
    }
    else
    {
      CanRxMsg.ID = ((u32)CAN0RXIDR0)<<3;
      CanRxMsg.ID |= ((u32)CAN0RXIDR1&0xe0)>>5;
    }        
  }
 
  return Status;
}

Any suggestion for polling mode?

best regrads,

0 项奖励

936 次查看
kef2
Senior Contributor IV
  • if(CAN0CTL0_RXFRM)
      {
        CAN0CTL0_RXFRM = 1;
        CAN0RFLG=0xC3;             /*clear flag*/

     

        CanRxMsg.Data[0] = CAN0RXDSR0;/*CAN rx message handle*/
        CanRxMsg.Data[1] = CAN0RXDSR1;
        CanRxMsg.Data[2] = CAN0RXDSR2;

  • ...

Instead of waiting for CAN0CTL0_RXFRM, clearing RXFRM, clearing RXF and finally reading buffer, you should wait only for CAN0RFLG_RXF, read data and only then clear RXF! Clearing RXF bit is what allows msCAN to shift next message from FIFO to CAN RX buffer!

Edward

0 项奖励

936 次查看
hbch
Contributor III

Hi,

I can only get message data from register DSR0-7, which are output of receiver buffer Rx4. This leads to the reception delay.

Is there any idea for obtain data from receiver buffer Rx0?

best regrads,

0 项奖励