by StuartL » Sat May 31, 2008 7:54 am
by StuartL
Sat May 31, 2008 7:54 am
I stand corrected on my original comment.
The 16-bit logic I remembered is from the ATMega128 reference manual in relation to the timers.
As the CPU internally uses a temporary register per timer you have to do the read/writes in a specific order, and frustratingly it's not even the same order
I quote from the reference guide:
To do a 16-bit write, the high byte must be written before the low byte. For a 16-bit read, the low byte must be read before the high byte.
In all cases I strongly recommend 16-bit operations for 16-bit registers when using C, that way the compiler has to get it right for the context you're setting the register in.
So apologies for the mis-guidance earlier, and yes you're right in that it hardly matters if the serial interface isn't running, but it is a bad habit to get into.
I stand corrected on my original comment.
The 16-bit logic I remembered is from the ATMega128 reference manual in relation to the timers.
As the CPU internally uses a temporary register per timer you have to do the read/writes in a specific order, and frustratingly it's not even the same order
I quote from the reference guide:
To do a 16-bit write, the high byte must be written before the low byte. For a 16-bit read, the low byte must be read before the high byte.
In all cases I strongly recommend 16-bit operations for 16-bit registers when using C, that way the compiler has to get it right for the context you're setting the register in.
So apologies for the mis-guidance earlier, and yes you're right in that it hardly matters if the serial interface isn't running, but it is a bad habit to get into.