the recive message is wrong but why?

cancel
Showing results for 
Search instead for 
Did you mean: 

the recive message is wrong but why?

486 Views
zhaowei961
Contributor III

can_message_t sendMsg = {
                 .cs = 0U,
                 .id = TX_MSG_ID,
                 .length = 64U
             };
can_message_t recvMsg;

void userparaminit(void)
{
 /*Initialize user params */
 /* Set information about the data to be sent
  *  - Standard message ID
  *  - Bit rate switch enabled to use a different bitrate for the data segment
  *  - Flexible data rate enabled
  *  - Use zeros for FD padding
  */
  can_buff_config_t buffCfg =  {
       .enableFD = true,
       .enableBRS = true,
       .fdPadding = 0U,
       .idType = CAN_MSG_ID_STD,
       .isRemote = false
      };
  /* Configure TX buffer with index TX_MAILBOX*/
  CAN_ConfigTxBuff(&can_pal1_instance, TX_MAILBOX, &buffCfg);
  /* Set information about the data to receive
     *  - Standard message ID
     *  - Bit rate switch enabled to use a different bitrate for the data segment
     *  - Flexible data rate enabled
     *  - Use zeros for FD padding
     */
 /* Configure RX buffer with index RX_MAILBOX */
 CAN_ConfigRxBuff(&can_pal1_instance, RX_MAILBOX, &buffCfg, RX_MSG_ID);
 /* Prepare message to be sent */
  /*Initialize send buff for test*/

}
void main(void)
{
  for(uint8_t i=0;i<64;i++)
  {
   sendMsg.data[i]=i;
  }
    /* Send the information via CAN */
    CAN_Send(&can_pal1_instance, TX_MAILBOX, &sendMsg);
    while(1)
    {
     CAN_Receive(&can_pal1_instance, RX_MAILBOX, &recvMsg);
    /* Wait until the previous FlexCAN receive is completed */
     while(CAN_GetTransferStatus(&can_pal1_instance, RX_MAILBOX) == STATUS_BUSY);
}

Work mode is loopback

code as above,the problem is :recvMsg I found is as follow:

01 02 03 04 05 06 07 08 0F 5A 38 02 94 00 00 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F.I dont know why ?CAN anybody help me ?Thanks.

It should be 

00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F

Labels (1)
0 Kudos
2 Replies

331 Views
PetrS
NXP TechSupport
NXP TechSupport

I modified can_pal demo example (SDK3.0.0) for loopback mode and 64byte payload and after testing on the EVB I see correct data received.

pastedImage_1.png

So see no issue here.

BR, Petr

0 Kudos

331 Views
alexandrunan
NXP Employee
NXP Employee

Where is the driver Init function ?! And what is the configuration of it ?!

If you configured the Driver in non FD mode will send only first 8 bytes of message. 

Second please check you functions return status in case something is not configured ok, will return a different status than STATUS_SUCCESS.

What version of SDK do you use ?

0 Kudos