can message is wrong,need help.CPU is S32K118

cancel
Showing results for 
Search instead for 
Did you mean: 

can message is wrong,need help.CPU is S32K118

406 Views
zhaowei961
Contributor III

/*CAN MESSAGE */
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)
{
bsp_init();
userparaminit();
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);
     UART_SendDataBlocking(&uart_pal1_instance, &recvMsg.length, 1, TIMEOUT);
     UART_SendDataBlocking(&uart_pal1_instance, (uint8_t *)&recvMsg.id, 4, TIMEOUT);
     UART_SendDataBlocking(&uart_pal1_instance, (uint8_t *)&recvMsg.data, 64, TIMEOUT);
    }
}
code as above.the problem is recvMsg.data 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 

but it is

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.

Labels (1)
0 Kudos
2 Replies

261 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

refer to https://community.nxp.com/thread/521359 

BR, Petr 

0 Kudos

261 Views
zhaowei961
Contributor III

It woks fine .Thank you very much.

0 Kudos