FlexCan controller sends uint32_t in big endian order, is there a way to switch to little endian

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

FlexCan controller sends uint32_t in big endian order, is there a way to switch to little endian

358 次查看
nickager
Contributor II
I am using the FlexCan API `FLEXCAN_TransferSendBlocking` to send data across the CAN bus from a iMXRT1064 to an iMX8MP. Monitoring the CAN bus with a logic analyser I see the data is sent in big endian order. Is there a way to switch to little endian order without translating the endian order before I pass the data to `FLEXCAN_TransferSendBlocking` (and similar)

The code snippet I'm using to send the data is:

 

union {
    float f;
    uint32_t i;
} floatToUint;

floatToUint.f = 1.234f; // 0x3f9df3b6

flexcan_frame_t txFrame;
txFrame.id     = FLEXCAN_ID_STD(TX_MB_ID);
txFrame.format = (uint8_t)kFLEXCAN_FrameFormatStandard;
txFrame.type   = (uint8_t)kFLEXCAN_FrameTypeData;
txFrame.length = sizeof(floatToUint)
txFrame.dataWord0 = floatToUint.i; // 0x3f9df3b6
FLEXCAN_TransferSendBlocking(CAN2, TX_MESSAGE_BUFFER_NUM, &txFrame)​

 

 

Output of logic analyser:
 
sending 1.234f (0x3f9df3b6)sending 1.234f (0x3f9df3b6)
0 项奖励
回复
3 回复数

340 次查看
nickager
Contributor II

Hello,

To clarify:

All ARM cores are running in little endian, so in the example I posted above `txFrame.dataWord0 = floatToUint.i` the data is passed to the SDK in little endian format however the FlexCAN controller sends it over the CAN bus in big endian format as I showed in the logic analyser trace. 

I can translate the endianness of all data sent and received from the FlexCAN controller, however my question was whether there is a way to switch the FlexCAN controller to use little endian across the CAN bus?

0 项奖励
回复

343 次查看
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello,

Peripherals always assume little-endian-aligned data arrives or

departs on their 32-bit APB.

So, maybe ARM core support both big and little ending, but the peripherals only support little ending.

Regards

 

 

0 项奖励
回复

294 次查看
nickager
Contributor II

Hello,

To clarify:

All ARM cores are running in little endian, so in the example I posted above `txFrame.dataWord0 = floatToUint.i` the data is passed to the SDK in little endian format however the FlexCAN controller sends it over the CAN bus in big endian format as I showed in the logic analyser trace. 

I can translate the endianness of all data sent and received from the FlexCAN controller, however my question was whether there is a way to switch the FlexCAN controller to use little endian across the CAN bus?

0 项奖励
回复