The datasheet of my microcontroller C8051F120 is clear on when it comes to reading the 16 bit value PCA0L and PCA0H:
“Reading PCA0L automatically latches the value of PCA0H into a “snapshot” register; the following PCA0H read accesses this “snapshot” register. Reading the PCA0L Register first guarantees an accurate reading of the entire 16-bit PCA0 counter.”
However, I did not find a similar statement regarding the TMRnL and TMRnH registers. I remember on an Atmega128CAN90, I have used the following
unsigned char chL,chH;
#asm("cli")
chL=TCNT3L;
chH=TCNT3H;
#asm("sei")
Does anybody knows if the above quote also holds for the TMRnL and TMRnH registers of the C8051F120? Or, what is a safe way to get a consistent reading? Do interrupts need to be disabled?
Thanks for your help!
Page 116 of the datasheet says:
So it does appear a similar thing is happening.