Side effects and sequence points; why volatile matters - Sticky Bits - Powered by Feabhas
Introduction Most embedded programmers, and indeed anyone who has attended a Feabhas programming course, is familiar with using the volatile directive when accessing registers. But it is not always obvious the ‘whys and wherefores’ of the use of volatile. In this article, we explore why using volatile works, but more importantly, why it is needed in the first place. Peripheral register access If we start with a simple, fictitious, example. Suppose we have a peripheral with the following register layout: register width offset control byte 0x00 configuration byte 0x01 data byte 0x02 status byte 0x03 with a base address of [...]
Sticky Bits - Powered by Feabhas