Appendix a: little and big endians, Appendix a – ElmoMC CANopen DS 301 Implementation Guide User Manual

Page 118

Advertising
background image

Appendix A: Little and Big Endians

The “end” in “endians” refers to the address of the most significant or least significant
byte in a multiple-byte data type (such as short, long or float). The address of big endians
is the most significant byte (the “big” end) while the address of little endians is the least
significant byte (the “little” end).

Example using standard C conventions:
long lType;

short sType[2]

char cType[5] = “ABCD”;

lType = 0x12345678;

sType[1] = 0x1234 ;

sType[2] = 0x5678 ;

Memory structure: big endians (starts with MSB):
00 08
12 34 56 78 - lType
12 34 56 78 - sType
AB CD 0 - cType

Memory structure: little endians (starts with LSB):
00 08
78 56 34 12 - lType
34 12 78 56 - sType
AB CD 0 - cType

The CANopen protocol supports the little endian method; for example, a node replies to
a TPDO with three objects:
Object 1: Signed24 - 0x12ABCD
Object 2: Unsigned32 - 0x123456AB
Object 3: Unsigned8 - 0x1F

The CAN octet will be as follows:
CD AB 12 AB 56 34 12 1F

CANopen DS 301 Implementation Guide

Initial CAN Communication Setup

MAN-CAN301IG (Ver. 2.1)

A-1

Advertising