×

Sale ends todayGet 30% off any course (excluding packages)

Ends in --- --- ---

CAN Bus Communications Decoded: Big Endian and Little Endian

Watch This Course

$199 USD

-OR-
Or 8 easy payments of only $24.88 Instant access. Easy checkout. No fees. Learn more
Course Access for Life
60 day money back guarantee

Big Endian and Little Endian

03.09

00:00 - Big endian and little endian are quite odd terms if you've not encountered them before.
00:05 But they're also quite descriptive and really mean what they say.
00:08 In the previous course section, we talked about bits and bytes and how in particular, a byte is made up of 8 bits and has a maximum value of 255.
00:19 What happens though if you want to transmit a value that is higher than 255? You can do this using 2 bytes and making sure all the electronic components in the system are configured to know that these 2 bytes are meant to be read together.
00:32 This has the effect of allowing you to transmit a single piece of data that is 16 bits long.
00:38 You can now have a maximum value of When we do this, we call one of these bytes the low byte and the other the high byte.
00:49 The low byte contains the least significant digits of the value, the lower 8 bits.
00:55 With the high byte containing the most significant digits, the upper 8 bits.
01:00 However, there's no completely agreed upon standard regarding the order in which these bytes should be transmitted.
01:06 If a device is configured to send out the low byte first, followed by the high byte and another device is configured to read the first byte as the high byte with the second byte as the low byte, these 2 devices will not agree on the value that those 16 total bits represent.
01:21 This is where you see the terms big endian and little endian.
01:24 These are the names given fo the 2 different ways the byte transmission order can be configured.
01:30 Little endian means that the first byte received contains the least significant bits while big endian is the opposite with the first byte received being the most significant bits.
01:40 Let's have a look at a quick example.
01:43 Say we want to transmit the current exhaust gas temperature in a turbocharged car.
01:47 We can reliably expect this to be a few hundred degrees so using 2 bytes to transmit this value in 16 bits makes sense.
01:54 Let's assume the current exhaust gas temperature reading is 650°C, converting this into hexadecimal, we donate this as 0x028A.
02:04 We can split this up into the high byte being 0x02 and the low byte being 0x8A.
02:12 Remembering from the previous module that it's really convenient to represent our single bytes in hexadecimal.
02:17 If our exhaust gas temp sensor interface sends out this data in little endian format, so that means our low byte first, but our ECU is configured to receive the data in big endian format, it will reconstruct the 16 bit value incorrectly, ending up with 0x8A02.
02:34 Which when we convert back to decimal gives a value of 33794°C.
02:39 This is obviously wrong and would likely be flagged by the ECU as an erroneous value and give us a warning to investigate it.
02:47 But that's not something you want to rely on happening because the consequences of devices being misconfigured in this way can actually be quite hard to predict.
02:55 Both big endian and little endian work but all the devices communicating on the network need to be configured to read and reconstruct the data as it was intended by the transmitter.

We usually reply within 12hrs (often sooner)

Need Help?

Need help choosing a course?

Experiencing website difficulties?

Or need to contact us for any other reason?