Mixing 32bit and 16bit code (comming down into real mode)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Mixing 32bit and 16bit code (comming down into real mode

Post by Brendan »

Hi,
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.
When the 32-bit value changes, what prevents "atomicity" problems?

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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply