<?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 Time Of Day interrupt shared by Second and Match in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Time-Of-Day-interrupt-shared-by-Second-and-Match/m-p/284175#M20326</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;BR /&gt; I haven't posted for a while and things look different from what I remember, so I hope I'm in the right place.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use the Time Of Day module with both a one-second and a timer match interrupt.&lt;BR /&gt;As both these interrupts use the same interrupt vector, I want to differentiate between them in the interrupt routine.&lt;BR /&gt;I thought this would just involve checking which interrupt flag(s) were set and performing the appropriate actions. However, clearing the one-second interrupt flag TODSC_SECIE appears to also clear the match interrupt flag TODSC_MTCHF.&lt;/P&gt;&lt;P&gt;I have interrupts disabled while stepping, but it looks as if the time of day counter may still be running while the micro is halted?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I know I do not need to do things this way, I currently have a 60s count in the one second interrupt, but I'm looking at using the match interrupt to provide a variable delay and keep the micro in Stop3 for longer and only use the one-second interrupt as necessary. For this I want to make sure the two interrupt flags are truely separately clearable.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Micro MC9S08LL8&lt;BR /&gt;Code Warrior 6.1&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Jun 2013 11:56:00 GMT</pubDate>
    <dc:creator>DRichards</dc:creator>
    <dc:date>2013-06-10T11:56:00Z</dc:date>
    <item>
      <title>Time Of Day interrupt shared by Second and Match</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Time-Of-Day-interrupt-shared-by-Second-and-Match/m-p/284175#M20326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;BR /&gt; I haven't posted for a while and things look different from what I remember, so I hope I'm in the right place.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use the Time Of Day module with both a one-second and a timer match interrupt.&lt;BR /&gt;As both these interrupts use the same interrupt vector, I want to differentiate between them in the interrupt routine.&lt;BR /&gt;I thought this would just involve checking which interrupt flag(s) were set and performing the appropriate actions. However, clearing the one-second interrupt flag TODSC_SECIE appears to also clear the match interrupt flag TODSC_MTCHF.&lt;/P&gt;&lt;P&gt;I have interrupts disabled while stepping, but it looks as if the time of day counter may still be running while the micro is halted?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I know I do not need to do things this way, I currently have a 60s count in the one second interrupt, but I'm looking at using the match interrupt to provide a variable delay and keep the micro in Stop3 for longer and only use the one-second interrupt as necessary. For this I want to make sure the two interrupt flags are truely separately clearable.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Micro MC9S08LL8&lt;BR /&gt;Code Warrior 6.1&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&lt;SPAN class="mce_paste_marker"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jun 2013 11:56:00 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Time-Of-Day-interrupt-shared-by-Second-and-Match/m-p/284175#M20326</guid>
      <dc:creator>DRichards</dc:creator>
      <dc:date>2013-06-10T11:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Time Of Day interrupt shared by Second and Match</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Time-Of-Day-interrupt-shared-by-Second-and-Match/m-p/284176#M20327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume that you are attempting to clear the flags using -&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;TODSC_SECF = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;TODSC_MTCHF = 1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, with more than one flag within the register, this code will have the effect of clearing all flags, as you have observed.&amp;nbsp; The reason lies with the compiler using a read-modify-write process within the generated code, i.e BSET command.&amp;nbsp; Any of the bits, other than the specified bit, will also read as a 1, if set.&amp;nbsp; The bits will then be written back to the register as 1s, which will clear all the flag bits.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution is to use a write only process -&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;#define TODSCval 0x0E;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;TODSC = TODSCval | TODSC_SECF_MASK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;TODSC = TODSCval | TODSC_MTCHF_MASK;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the TOD counter is to be used as a wakeup source, it would need to be running whilst the MCU is in stop mode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Mac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jun 2013 13:27:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Time-Of-Day-interrupt-shared-by-Second-and-Match/m-p/284176#M20327</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2013-06-10T13:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Time Of Day interrupt shared by Second and Match</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Time-Of-Day-interrupt-shared-by-Second-and-Match/m-p/284177#M20328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried the suggesstion and it works. Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jun 2013 14:15:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Time-Of-Day-interrupt-shared-by-Second-and-Match/m-p/284177#M20328</guid>
      <dc:creator>DRichards</dc:creator>
      <dc:date>2013-06-10T14:15:04Z</dc:date>
    </item>
  </channel>
</rss>

