SUPERPIE
SUPERPIE

Reputation: 1

How will be the bit stuffing applied to the identifier field 0x03E? (CAN PROTOCOL)

Suppose we are transmitting a message with identifier 0x03E.

Its binary in 11 bit form is 000 0011 1110. So while transmitting this how will it get stuffed?

After transmitting the first five zeros there will be a stuffed bit -> 000001.Then in the identifier there are 5 consecutive ones' present so my doubt is will it transmit the 5 consecutive 1s and then add an opposite polarity bit (that will make the transmitted bit stream 0000011111100) or transmit 4 consecutive 1s and then add a stuffed bit ( transmitted bit stream 0000011111010).

Thanks in advance!!

Upvotes: 0

Views: 84

Answers (1)

Lundin
Lundin

Reputation: 213892

Its binary in 11 bit form is 000 0011 1110

That's irrelevant because bit stuffing occurs on the frame level. All CAN frames start with a dominant 0 bit called Start of Frame. So in case the 11 bit CAN ID is 0x03E, then the unstuffed frame will look like:

0 000 0011 1110

(CAN frames always use big endian encoding.)

The first stuffing bit is inserted after the first 5 consecutive zeroes:

00000>1<0111110

The next stuffing bit will get inserted after the 5 consecutive ones:

000001011111>0<0

And so the bit stream will become:

00000101111100

Does a programmer need to know and care about this? Not really - the stuffing bits are added/removed by the CAN controller and you won't ever see them on the software side.

The only time you need to know about them is when manually decoding CAN frames with an oscilloscope, which is pretty pointless practice because 1) most scopes have built-in protocol decoding these days and 2) using a CAN listener is so much more convenient anyway.

Knowing about stuffing bits does matter when calculating bus load and transmission times however, so from the real-time design side, you ought to know about them.

Upvotes: 0

Related Questions