When the 32-bit value changes, what prevents "atomicity" problems?bobjohnson2121 wrote:Here is why I am asking: I have an ambient pressure (altitude) sensor that is malfunctioning from time to time. I communicate with the sensor from a Freescale Microcontroller (MCF52223) using SPI, well Motorolla/Freescale/Google's version of SPI - QSPI. There are two 16 bit integers I read to create a 32 bit integer which I then run through an equation to calculate ambient pressure. Generally the data comes in fine, but once in a blue moon the two integers I read in are 0x100 and 0xFEFF which turns into 0x100FEFF, and is not the correct data.
For example; if the value goes from 0x01000000 to 0x00FFFFFF while you're trying to read the value, what prevents you from reading the old high 16-bits (0x0100) then the new low 16-bits (0xFFFF) and ending up misreading the value as 0x0100FFFF?
Cheers,
Brendan