AnsweredAssumed Answered

MPC5777C: Latest SDK: MCAN Driver

Question asked by hemadri payam on Jun 18, 2019
Latest reply on Jul 2, 2019 by Jorge Antonio Alcala Vazquez

Hi,

 

I am working on MPC5777C and using the latest SDK for mCAN.

In the function MCAN_StartSendData, mcan_mb_data_32 (which is a pointer to message RAM) is updated with the msgData_32 (which is a pointer to the data to be transmitted).

 

MCAN driver code:


if (mb_data != NULL)
{
dlc_value = MCAN_GetTxPayloadSize(base);
uint8_t payload_size = MCAN_ComputeTxPayloadSize(dlc_value);

for (databyte = 0; databyte < (tx_info->data_length & ~3U); databyte += 4U)
{
REV_BYTES_32(msgData_32[databyte >> 2U], mcan_mb_data_32[databyte >> 2U]);
}
for ( ; databyte < tx_info->data_length; databyte++)
{
/* Write access is allowed only as 32 bits to message ram */
uint32_t aux = mb_data[databyte];
mcan_mb_data_32[databyte >> 2U] = mcan_mb_data_32[databyte >> 2U] | (aux << ((databyte & 3U) << 3U));
}
/* Add padding, if needed */
for (databyte = tx_info->data_length; databyte < payload_size; databyte++)
{
/* Write access is allowed only as 32 bits to message ram */
mcan_mb_data_32[databyte >> 2U] = mcan_mb_data_32[databyte >> 2U] | ((uint32_t)tx_info->fd_padding << ((databyte & 3U) << 3U));
}
}

 

the driver works fine if the data length is in the multiples of 4.

If the data length is not in the multiples of 4, then the Message RAM (mcan_mb_data_32) is Ored with the previous data of message RAM. So the transmitted data is not the same as msgData_32 (data to be sent).

 

Can we reset the Message RAM before updating it with the data to be sent or does NXP has any other better solution for the same.

 

Regards,

Hemadri

Outcomes