<?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 Re: real time interrupts in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207911#M8043</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The crystal is 2Mhz, and was used for this project in the past, we are in the process of upgrading to this microprocessor, and I can't even figure out how to set up the ISR code properly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 21 May 2011 00:39:06 GMT</pubDate>
    <dc:creator>russianspy1234</dc:creator>
    <dc:date>2011-05-21T00:39:06Z</dc:date>
    <item>
      <title>real time interrupts</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207909#M8041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am using a MC9S08MP16 with an external crystal for a clock.&amp;nbsp; I am trying to get my program to hold for a very specific amount of time (3.24 seconds), but I can't seem to figure out how to use the RTI flags.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2011 01:27:40 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207909#M8041</guid>
      <dc:creator>russianspy1234</dc:creator>
      <dc:date>2011-05-20T01:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: real time interrupts</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207910#M8042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, and welcome to the forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The suitability and approach to using the RTI (or maybe MTIM) for generating a 3.24 second delay will depend on the timing accuracy that you require, and the crystal frequency you are using.&amp;nbsp; Some crystal frequencies will be more convenient than others, and potentially produce greater accuracy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, if you were using a 32.768 kHz watch crystal as&amp;nbsp;the external reference, your required timing period would be&amp;nbsp;represented by 106168 clock cycles.&amp;nbsp; This has factors of&amp;nbsp;8 x 23 x 577.&amp;nbsp; The last factor exceeds an 8-bit modulo count.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this example, the approach might be to set the RTI modulo value to 184 (8 x 23), with a prescale value of 1.&amp;nbsp; This would generate an interrupt every 5.62 milliseconds.&amp;nbsp; Within the ISR code, you might decrement a global variable that starts with an initial value of 577.&amp;nbsp; When the variable decrements to zero, the required&amp;nbsp;delay period would have elapsed.&amp;nbsp; Make sure that you clear the RTI flag within the ISR code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With a selected higher frequency crystal, you might be able to make use of the prescaler, and possibly achieve the delay period with a single interrupt, i.e. with a prescaled clock of 50Hz, and a modulo value of 162, or maybe a prescaled&amp;nbsp;clock of 75Hz,&amp;nbsp;and a modulo value of 243.&amp;nbsp; Of course, the crystal frequency&amp;nbsp;will also need&amp;nbsp;to be suitable&amp;nbsp;for the external reference range needed by the ICS module.&amp;nbsp; With this approach, crystal frequencies of 5.000 MHz or 4.9152 MHz would appear suitable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For future reference, threads concerning the operation of the HCS08 MCU hardware would usually be posted in the 8-bit forum.&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>Fri, 20 May 2011 13:00:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207910#M8042</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2011-05-20T13:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: real time interrupts</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207911#M8043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The crystal is 2Mhz, and was used for this project in the past, we are in the process of upgrading to this microprocessor, and I can't even figure out how to set up the ISR code properly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 May 2011 00:39:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207911#M8043</guid>
      <dc:creator>russianspy1234</dc:creator>
      <dc:date>2011-05-21T00:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: real time interrupts</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207912#M8044</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;To achieve a timing resolution of 10ms, the output of the RTC prescaler should be 10Hz, or a multiple.&amp;nbsp; Using a 2MHz crystal, a prescale setting of 20,000 would be suitable.&amp;nbsp; However, a timeout period of 3.24 seconds would represent a total count of 324 prescaler output cycles, which cannot be directly achieved with the 8-bit modulo value of the RTC.&amp;nbsp; It would then be necessary to use a minimum of&amp;nbsp;two interrupts (each with 1.62 second period) to achieve the required period.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following untested code snippet attempts to demonstrate this operation.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;byte RTIcount;&amp;nbsp; // Global variable&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;void timer_start( void)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; RTIcount = 2;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; RTCMOD = 162;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; RTCSC = 0xBC; // Clear flag and enable interrupt&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; // Action required at start of timing period&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;interrupt void ISR_RTC( void)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;{&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; RTIcount--;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; if (RTIcount == 0) {&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RTCSC = 0xAC;&amp;nbsp; // Clear flag &amp;amp; disable further interrupts&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Action required at end of timing period&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; else {&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RTCSC = 0xBC;&amp;nbsp; // Clear flag &amp;amp; continue interrupts&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;Mac&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 May 2011 02:50:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207912#M8044</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2011-05-21T02:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: real time interrupts</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207913#M8045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, that is really helpful.&amp;nbsp; I am not too worried about how many times I need to call the interupt, since nothing (codewise) needs to happen while the program is waiting, it's all taken care of by attached hardware.&amp;nbsp; I am really new to programming microprocessors, I am still having some trouble setting up the bits for ICSC1, ICSC2, and ICSSC to properly use my external crystal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 May 2011 02:59:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207913#M8045</guid>
      <dc:creator>russianspy1234</dc:creator>
      <dc:date>2011-05-21T02:59:35Z</dc:date>
    </item>
    <item>
      <title>Re: real time interrupts</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207914#M8046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Remember you can use for more precision the TPM module.&lt;/P&gt;&lt;P&gt;Regards!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 06:12:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/real-time-interrupts/m-p/207914#M8046</guid>
      <dc:creator>JorgeOchoa</dc:creator>
      <dc:date>2011-07-28T06:12:06Z</dc:date>
    </item>
  </channel>
</rss>

