bigmac

HC(S)08: Write sequence for STHX instruction

Discussion created by bigmac on Jun 14, 2007
Latest reply on Jun 17, 2007 by bigmac
Hello all,
 
When writing values to some of the peripheral word registers, particularly for the HC908 devices, it is necessary to write the low byte last, after writing the high byte.  Similar issues can also apply when reading the word registers.  For the HCS08 devices, the write sequence does not appear to be as critical.
 
For unambiguous sequencing, of course each byte of the word can be individually written or read.  However, it would seem more efficient if both bytes can be written using the STHX instruction.  This raises the issue of the detailed operation of the instruction - is the write sequence of the individual bytes compatible with the write requirements of the peripheral registers?
 
For some registers the use of STHX does appear to be OK.  I have successfully written to the timer modulo register (before I realised it had the write sequencing constraint).  To verify this the question remains, where can I find this detailed information about the sequence of operations within each instruction?
 
Incidently, in response to the statement -
TMOD = 0x7FFF;
the CW compiler appears to generate the following instructions -
LDHX  #$7FFF
STHX  TMOD
 
Thank you for any help in clarifying this issue.
 
Regards,
Mac
 

Outcomes