MPC5777C: Latest SDK: MCAN Driver

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

MPC5777C: Latest SDK: MCAN Driver

570 Views
hemadri_payam
Contributor III

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

0 Kudos
1 Reply

479 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Hemadri Payam

Sorry for the late reply, we have been in a great load of work. About your comments, yes, I think one optioned that you could use is reset the buffer. As the comments in the code mentioned "/* Write access is allowed only as 32 bits to message ram */" this is why this part is implemented in this way.

Best regards

0 Kudos