<?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>8-bit MicrocontrollersのトピックData Coherency issue - MC9S08DZ60</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200463#M16366</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using the MC9S08DZ60 and utilizing overflow of TPM1 to generate an interrupt every 1ms for my time base.&amp;nbsp; I am having coherency issues when using a 16 bit (unsigned int) variable as a timer even though I stop interrupts before loading the number.&amp;nbsp; Looking at a port I toggle, I have proved that the high byte is being decremented occasionally before the low byte is loaded giving me 44ms (0x2c) instead of 300ms (0x12c). Below is a simplified example (COSMIC tools, not CodeWarrior).&amp;nbsp; I'm at my wits end and any suggestions would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void main(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned int x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;while(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _asm("sei\n");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = 300;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _asm("cli\n");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(x)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; /* Do something */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;@interrupt IntTime(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; TPM1SC &amp;amp;=0x7F;&amp;nbsp;&amp;nbsp;&amp;nbsp; //RESET INTERRUPT FLAG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if(x) x--;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Added p/n to subject.&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by NLFSJ on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-17&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;03:35 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by NLFSJ on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-17&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;03:36 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by NLFSJ on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-17&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;03:37 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 18 Jul 2009 05:23:59 GMT</pubDate>
    <dc:creator>jafriede</dc:creator>
    <dc:date>2009-07-18T05:23:59Z</dc:date>
    <item>
      <title>Data Coherency issue - MC9S08DZ60</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200463#M16366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Using the MC9S08DZ60 and utilizing overflow of TPM1 to generate an interrupt every 1ms for my time base.&amp;nbsp; I am having coherency issues when using a 16 bit (unsigned int) variable as a timer even though I stop interrupts before loading the number.&amp;nbsp; Looking at a port I toggle, I have proved that the high byte is being decremented occasionally before the low byte is loaded giving me 44ms (0x2c) instead of 300ms (0x12c). Below is a simplified example (COSMIC tools, not CodeWarrior).&amp;nbsp; I'm at my wits end and any suggestions would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;void main(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned int x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;while(1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _asm("sei\n");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = 300;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _asm("cli\n");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(x)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; /* Do something */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;@interrupt IntTime(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; TPM1SC &amp;amp;=0x7F;&amp;nbsp;&amp;nbsp;&amp;nbsp; //RESET INTERRUPT FLAG&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if(x) x--;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Added p/n to subject.&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by NLFSJ on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-17&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;03:35 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by NLFSJ on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-17&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;03:36 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by NLFSJ on&lt;/SPAN&gt; &lt;SPAN class="local-date"&gt;2009-07-17&lt;/SPAN&gt; &lt;SPAN class="local-time"&gt;03:37 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Jul 2009 05:23:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200463#M16366</guid>
      <dc:creator>jafriede</dc:creator>
      <dc:date>2009-07-18T05:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: Data Coherency issue - MC9S08DZ60</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200464#M16367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While I am not familiar with the Cosmic compiler, and the way it handles local variables declared within main(), I would not expect your code to work.&amp;nbsp; With CW compiler, the variable &lt;EM&gt;x&lt;/EM&gt; would need to be a global variable for the ISR function to have visibility of this variable.&amp;nbsp; The variable should also be declared as &lt;EM&gt;volatile&lt;/EM&gt; because the ISR code does write to the variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 18 Jul 2009 08:59:21 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200464#M16367</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2009-07-18T08:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Data Coherency issue - MC9S08DZ60</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200465#M16368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mac,&lt;/P&gt;&lt;P&gt;&amp;nbsp; You are absolutely right.&amp;nbsp; I was typing this out late Friday before I went home and messed it up.&amp;nbsp; The variable is global and declared as volatile.&amp;nbsp; My purpose was just to show the basic framework of what I'm trying to accomplish.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2009 21:42:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200465#M16368</guid>
      <dc:creator>jafriede</dc:creator>
      <dc:date>2009-07-20T21:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Data Coherency issue - MC9S08DZ60</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200466#M16369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;I trhink we have a misunderstanding.&amp;nbsp; The solution is not accepted.&amp;nbsp; The typos were in my post, not with my application code.&amp;nbsp; Problem is still there.&amp;nbsp; Do I need to start a new thread?&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jul 2009 23:16:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200466#M16369</guid>
      <dc:creator>jafriede</dc:creator>
      <dc:date>2009-07-21T23:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: Data Coherency issue - MC9S08DZ60</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200467#M16370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since the low byte must be already zero for the high byte to decrement, you might try first loading a dummy value with non-zero low byte, and then immediately load the required value.&amp;nbsp; But this shouldn't be necessary if interrupts are actually being disabled prior to the write.&amp;nbsp;Perhaps this might be a problem with the compiler.&amp;nbsp; Is it possible to view the assembly code that the compiler is generating?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data coherency should not be an issue if the word value is written with a single assembly instruction, i.e.&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ldhx #0x012C&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;sthx xvar&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps you should do some further tests by creating a very simple CW project, and see if the problem still persists.&amp;nbsp; If it does, you can then open a Service Request with Freescale.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jul 2009 14:30:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200467#M16370</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2009-07-22T14:30:41Z</dc:date>
    </item>
    <item>
      <title>Re: Data Coherency issue - MC9S08DZ60</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200468#M16371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mac,&lt;/P&gt;&lt;P&gt;&amp;nbsp; You somewhat indirectly solved my problem.&amp;nbsp; I was getting a "bad addressing mode" error when trying your ldhx example.&amp;nbsp; I finally figured out there is a "+hcs" option that needs to be set with the Cosmic compiler to generate hc08 code.&amp;nbsp; Thank you very much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jul 2009 04:22:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Data-Coherency-issue-MC9S08DZ60/m-p/200468#M16371</guid>
      <dc:creator>jafriede</dc:creator>
      <dc:date>2009-07-23T04:22:57Z</dc:date>
    </item>
  </channel>
</rss>

