<?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 Basic timer program in asm in CodeWarrior for MCU</title>
    <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Basic-timer-program-in-asm/m-p/153057#M3771</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;I´m really confused about the behavior of TPM, so I wonder if someone could give me a basic example of a program that uses a timer (TPM) in assembly language. I want, for example, to turn on a LED, wait 3 seconds and then turn off the LED. I'm using the microcontroller &lt;SPAN&gt;MC9S08QE128.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Apr 2012 12:48:14 GMT</pubDate>
    <dc:creator>MindMond</dc:creator>
    <dc:date>2012-04-11T12:48:14Z</dc:date>
    <item>
      <title>Basic timer program in asm</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Basic-timer-program-in-asm/m-p/153057#M3771</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;I´m really confused about the behavior of TPM, so I wonder if someone could give me a basic example of a program that uses a timer (TPM) in assembly language. I want, for example, to turn on a LED, wait 3 seconds and then turn off the LED. I'm using the microcontroller &lt;SPAN&gt;MC9S08QE128.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 12:48:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Basic-timer-program-in-asm/m-p/153057#M3771</guid>
      <dc:creator>MindMond</dc:creator>
      <dc:date>2012-04-11T12:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: Basic timer program in asm</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Basic-timer-program-in-asm/m-p/153058#M3772</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;Simple tasks involving long time delays, such as to control the flashing of a LED, do not usually require&amp;nbsp;very precise timing intervals (who would notice whether the LED flash was actually 2.9 or 3 seconds duration).&amp;nbsp; With this in mind, a frequently used approach is to divide the longer time interval into a sequence of much shorter intervals.&amp;nbsp; The period of the shorter interval will determine delay resolution and timing uncertainty.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The TPM module can be used for the shorter interval timing (or "tic" interval).&amp;nbsp; For this purpose, a TPM channel can be utilized, using software output compare mode.&amp;nbsp; Alternatively, the tic interval could be based on the period between TPM overflows&amp;nbsp;- an even simpler process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, if we assume a bus frequency of 8MHz, a prescale division by 4, and a free-running TPM, the TPM overflow period will be&amp;nbsp;32.77 ms.&amp;nbsp; A delay of approximately 3 seconds will require 92 overflow periods, with the actual delay being somewhere between 91 and 92 periods.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each delay "channel" of this type, and depending on the maximum delay required, you would define a RAM counter variable of either 8-bit or 16-bit size.&amp;nbsp; Within the TPM overflow ISR code you might have the following code for each 8-bit&amp;nbsp;variable, assuming that the variables are within zero page RAM.&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; LDA&amp;nbsp;&amp;nbsp; DLYCNT&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEQ&amp;nbsp;&amp;nbsp; *+4&amp;nbsp;&amp;nbsp;&amp;nbsp; ; Skip next if already zero&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEC&amp;nbsp;&amp;nbsp; DLYCNT&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;The following code&amp;nbsp;provides a sub-routine that does not exit until the delay period is complete.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;; DELAY SUB-ROUTINE:; On entry ACC = delay value in multiples of 31.77 msWAIT_DELAY:        STA  DLYCNTWD1:    ; Clear watchdog timer macro here        LDA  DLYCNT        BNE  WD1      ; Loop if no timeout        RTS&lt;/PRE&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>Thu, 29 Oct 2020 08:56:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Basic-timer-program-in-asm/m-p/153058#M3772</guid>
      <dc:creator>bigmac</dc:creator>
      <dc:date>2020-10-29T08:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Basic timer program in asm</title>
      <link>https://community.nxp.com/t5/CodeWarrior-for-MCU/Basic-timer-program-in-asm/m-p/153059#M3773</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, I will try to use that code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Apr 2012 12:20:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/CodeWarrior-for-MCU/Basic-timer-program-in-asm/m-p/153059#M3773</guid>
      <dc:creator>MindMond</dc:creator>
      <dc:date>2012-04-12T12:20:25Z</dc:date>
    </item>
  </channel>
</rss>

