<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic HC(S)08: Write sequence for STHX instruction in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136727#M4454</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Hello all,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;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.&amp;nbsp; Similar issues can also apply when reading the word registers.&amp;nbsp; For the HCS08 devices, the write sequence does not appear to be as critical.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;For unambiguous sequencing, of course each byte of the word can be individually written or read.&amp;nbsp; However, it would seem more efficient if both bytes can be written using the STHX instruction.&amp;nbsp; 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?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;For some registers the use of STHX does appear to be OK.&amp;nbsp; I have successfully written to the timer modulo register (before I realised it had the write sequencing constraint).&amp;nbsp; To verify this the question remains, where can I find&amp;nbsp;this detailed information about the&amp;nbsp;sequence of&amp;nbsp;operations&amp;nbsp;within each instruction?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Incidently, in response to the statement -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 2;"&gt;TMOD = 0x7FFF;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;the CW compiler appears to generate the&amp;nbsp;following instructions&amp;nbsp;-&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 2;"&gt;LDHX&amp;nbsp; #$7FFF&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 2;"&gt;STHX&amp;nbsp; TMOD&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Thank you for any help in clarifying this issue.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Regards,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Mac&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Jun 2007 12:30:58 GMT</pubDate>
    <dc:creator>bigmac</dc:creator>
    <dc:date>2007-06-14T12:30:58Z</dc:date>
    <item>
      <title>HC(S)08: Write sequence for STHX instruction</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136727#M4454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Hello all,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;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.&amp;nbsp; Similar issues can also apply when reading the word registers.&amp;nbsp; For the HCS08 devices, the write sequence does not appear to be as critical.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;For unambiguous sequencing, of course each byte of the word can be individually written or read.&amp;nbsp; However, it would seem more efficient if both bytes can be written using the STHX instruction.&amp;nbsp; 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?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;For some registers the use of STHX does appear to be OK.&amp;nbsp; I have successfully written to the timer modulo register (before I realised it had the write sequencing constraint).&amp;nbsp; To verify this the question remains, where can I find&amp;nbsp;this detailed information about the&amp;nbsp;sequence of&amp;nbsp;operations&amp;nbsp;within each instruction?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Incidently, in response to the statement -&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 2;"&gt;TMOD = 0x7FFF;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;the CW compiler appears to generate the&amp;nbsp;following instructions&amp;nbsp;-&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 2;"&gt;LDHX&amp;nbsp; #$7FFF&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-family: 'Courier New'; font-size: 2;"&gt;STHX&amp;nbsp; TMOD&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Thank you for any help in clarifying this issue.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Regards,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 2;"&gt;Mac&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jun 2007 12:30:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136727#M4454</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-06-14T12:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: HC(S)08: Write sequence for STHX instruction</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136728#M4455</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;/DIV&gt;Check HCS08RMV1 or CPU08RM documents.&lt;BR /&gt;&lt;BR /&gt;For each instruction there is a detailed description of the actions taken.&amp;nbsp; For example, for STHX it says:&lt;BR /&gt;&lt;BR /&gt;&lt;I&gt;Stores the contents of H in memory location M and then the contents of X into the next memory&lt;BR /&gt;location (M + $0001). The N condition code bit is set if the most significant bit of H was set, the Z bit&lt;BR /&gt;is set if the value of H:X was $0000, and V is cleared. This allows conditional branching after the store&lt;BR /&gt;without having to do a separate test or compare.&lt;BR /&gt;&lt;/I&gt;&lt;BR /&gt;So, H is saved first, then X.&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jun 2007 14:13:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136728#M4455</guid>
      <dc:creator>tonyp</dc:creator>
      <dc:date>2007-06-14T14:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: HC(S)08: Write sequence for STHX instruction</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136729#M4456</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Thank you for your answer.&amp;nbsp; So the STHX sequence for the write operation&amp;nbsp;is clear, but the the sequence for the read process (LDHX) remains ambiguous&amp;nbsp;- I am not sure I can assume it will be the same sequence as the write process.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I seem to recall having once seen a document that described what occurred for &lt;U&gt;each cycle&lt;/U&gt; of&amp;nbsp;each instruction, but I have not been able to find that document - it may have actually&amp;nbsp;been for the HC05 device.&amp;nbsp; Can anyone point me to&amp;nbsp;a similar&amp;nbsp;document for the HC908 and HCS08 device.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Jun 2007 23:24:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136729#M4456</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-06-15T23:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: HC(S)08: Write sequence for STHX instruction</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136730#M4457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;Hello Mac,&lt;BR /&gt;&lt;BR /&gt;&lt;B&gt;HCS08 Family - Reference Manual - HCS08RMV1.pdf&lt;BR /&gt;&lt;/B&gt; gave me a page for each instruction and access details:&lt;BR /&gt;&lt;BR /&gt;Instruction&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add Mode&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Opcode&amp;nbsp;&amp;nbsp; Cycle&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Access Detail&lt;BR /&gt;STHX opr8a &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; DIR &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 35 dd&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; wwpp&lt;BR /&gt;STHX opr16a &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; EXT &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 96 hh ll&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pwwpp&lt;BR /&gt;STHX oprx8,SP &amp;nbsp;&amp;nbsp;&amp;nbsp; SP1 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9E FF ff&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pwwpp&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Alban.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Jun 2007 02:31:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136730#M4457</guid>
      <dc:creator>Alban</dc:creator>
      <dc:date>2007-06-16T02:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: HC(S)08: Write sequence for STHX instruction</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136731#M4458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello Alban,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The instructions of specific interest are&lt;FONT color="#FF0033"&gt;&lt;FONT face="Courier New"&gt;LDHX opr8a&lt;/FONT&gt;&lt;/FONT&gt; and&lt;FONT color="#FF0033"&gt;&lt;FONT face="Courier New"&gt;STHX opr8a&lt;/FONT&gt;&lt;/FONT&gt; since my query pertains to I/O registers.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;The reference manual tells me that the LDHX instruction uses two read cycles, and the STHX instruction uses two write cycles.&amp;nbsp; However, the manual does not indicate (except for the STHX case, as previously covered) which read/write cycle is for H, and which cycle is for X.&amp;nbsp; Additionally, the manual is for the HCS08 - I am not sure I can assume the HC908 would be&amp;nbsp;the same&amp;nbsp;since there are&amp;nbsp;differences in many instruction cycles.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;For the HC908 devices, whether or not these instructions can be utilised for the reading or writing of certain word registers requires that the high byte (H) be read or written first, followed by the low byte (X).&amp;nbsp; So the byte sequence is very important for these cases.&amp;nbsp; The word registers that have these requirements are -&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;ADC10 module:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;ADR requires sequenced reading&amp;nbsp;of 10-bit value.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;TIM module:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;TMOD requires sequenced write.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;TCNT requires sequenced read.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;TCHx register for each channel requires sequenced read for IC mode, and sequenced write for OC and PWM modes.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;It has been established that the write sequence for STHX is correct,&amp;nbsp;but the read sequence for LDHX still remains uncertain.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Jun 2007 23:37:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136731#M4458</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-06-16T23:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: HC(S)08: Write sequence for STHX instruction</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136732#M4459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Hello,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;I have now found an answer to this issue, at least for the TIM registers.&amp;nbsp; The document TIM08RM (TIM Reference Manual) does explicitly state that the instructions STHX and LDHX may be used to write and read the various word registers associated with the TIM.&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Regards,&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;Mac&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 17 Jun 2007 10:03:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/HC-S-08-Write-sequence-for-STHX-instruction/m-p/136732#M4459</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2007-06-17T10:03:02Z</dc:date>
    </item>
  </channel>
</rss>

