CAN mssgs dont retrieve

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CAN mssgs dont retrieve

740 Views
nishantsood
Contributor III

I have checked my device serving the CAN messages with IXXAT CAN sniffer as well as the Arduino and it receives all the messages except my S32k EVB:

My setup is connected with CAN H & L and GND with the following code for reading the IDs: "0x361" & "0x319"


int main(void)
{
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
#ifdef PEX_RTOS_INIT
PEX_RTOS_INIT(); /* Initialization of the selected RTOS. Macro is defined by the RTOS component. */
#endif
/*** End of Processor Expert internal initialization. ***/

/* Do the initializations required for this application */
BoardInit();
#ifdef EVB
SBCInit();
#endif
GPIOInit();
FlexCANInit();
CSEC_DRV_Init(&csec1_State);
/

/* Set information about the data to be received
* - 1 byte in length
* - 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
*/

/* Send the information via CAN */
flexcan_data_info_t dataInfo =
{
.data_length = 1U,
.msg_id_type = FLEXCAN_MSG_ID_EXT,
.enable_brs = true,
.fd_enable = true,
.fd_padding = 0U
};

/* Wait until the previous FlexCAN receive is completed */
//while(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, RX_MAILBOX) == STATUS_SUCCESS);

FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 2UL, &dataInfo, 0x361);
FLEXCAN_DRV_SetRxIndividualMask(INST_CANCOM1, FLEXCAN_MSG_ID_EXT, 2UL, 0x000u);

printf("setup - done\n");
while(1)
{

//LPUART_DRV_SendData(INST_LPUART1, (uint8_t *)welcomeMsg, strlen(welcomeMsg));
/* Define receive buffer */
flexcan_msgbuff_t recvBuff;

/* Start receiving data in RX_MAILBOX. */
FLEXCAN_DRV_Receive(INST_CANCOM1, 2UL, &recvBuff);

//printf("ScanComplete\n");
/* Wait until the previous FlexCAN receive is completed */
while(FLEXCAN_DRV_GetTransferStatus(INST_CANCOM1, 2UL) == STATUS_SUCCESS);


// Send the information via CAN
flexcan_data_info_t dataInfo =
{
.data_length = 1U,
.msg_id_type = FLEXCAN_MSG_ID_EXT,
.enable_brs = true,
.fd_enable = true,
.fd_padding = 0U
};

delayCycles(3200000);
printf("Msg ID: %x \n", (unsigned int)recvBuff.msgId);
switch(recvBuff.msgId){
case RX_MSG_ID:
printf("Msg ID: 0x%x \n", (unsigned int)recvBuff.msgId);
cell4 = recvBuff.data[2];//((uint16_t)recvBuff.data[7] << 8 ) + recvBuff.data[6] ;
uint8_t cell4_accumm[20] = {0,};
//LPUART_DRV_SendData(INST_LPUART1, (uint8_t *)buffer, strlen(buffer));
printf("Batt Current: %d \n", cell4);
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 2UL, &dataInfo, 0x361);
break;
case 0x361:
printf("Msg ID: 0x%x \n", (unsigned int)recvBuff.msgId);
uint32_t cell4 = ((uint32_t)recvBuff.data[7] << 32 ) + ((uint32_t)recvBuff.data[6] << 16 ) + ((uint32_t)recvBuff.data[5] << 8 ) + recvBuff.data[4];
//LPUART_DRV_SendData(INST_LPUART1, (uint8_t *)buffer, strlen(buffer));
printf("RPM: %d \n", cell4);
FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1, 2UL, &dataInfo, 0x319);
break;

default:

break;
}

if (useEncryption)
{
/* Check the length of the received message */
if (recvBuff.dataLen == 16)
{
status_t stat;
//printf("Data len: %d \n", recvBuff.dataLen);

/* Decrypt data using AES-128 ECB and the first non-volatile user key */
//stat = CSEC_DRV_DecryptECB(CSEC_KEY_1, recvBuff.data, 16UL, recvBuff.data, 1UL);

if (stat != STATUS_SUCCESS)
{
continue;
}
}
else
{
continue;
}
}

}

but all I receive is some random ID like: e873c887 and not the IDs: "0x361" and/or "0x319"

0 Kudos
0 Replies