Background: I'm using an NXP MCU and the CANopen protocol stack provided in the SDK package (EmSA CANopen (FD) Libraries for NXP SDKs). Most of the code is enclosed in the .a library files, and the hardware CAN module part is also included in these .a library files. So, I can't see the code of the CAN module and am unable to troubleshoot the issues. According to the ChangeLogKSDK.txt document, the protocol stack version is 7.10_rev1.
Problem: When using a CAN analyzer's PC software as the host computer to send RPDO to the MCU, I've encountered a problem. For some reason, the host computer needs to send one more byte for the MCU to enter the MCOUSER_RPDOReceived callback function. For example, if the mapping object of the RPDO in the object dictionary is set to 4 bytes (e.g., 0x20120020, where the last 0x20 indicates 4 bytes), the DLC (Data Length Code) on the host computer needs to be set to 5 bytes (or more) for the MCU to successfully receive the data, execute the callback, and successfully set the content in the object dictionary. (The code for setting the values in the object dictionary is not in the callback; the callback is just for users to write additional application code.) Otherwise, not only will the callback not be executed, but the content in the object dictionary will not change either.
For instance, if 1 byte is set, the DLC needs to be set to 2 bytes for the MCOUSER_RPDOReceived callback function to execute and obtain the correct data. This pattern continues in a similar manner.
If 8 bytes are set, when the DLC is less than or equal to 8, the situation is the same as above, and the callback will not be executed. However, if the DLC is greater than 8, the data received in the MCOUSER_RPDOReceived callback function will be garbled, and the content in the object dictionary cannot be changed, meaning the setting fails.
What could be the reason for this? Is it a certain setting inherent in the CANopen protocol? Is there a macro that can turn on or off this setting?#RT1170-EVK