<?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のトピックRe: MC9S08QG8 : Problem with a timer.</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307292#M20695</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Maria,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for late response. Firstly please accept my apology for my wrong answer before. I red those decription about Fixed Clock again, I believe now I can catch the meaning. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1). In FLL engaged mode (FEI and FEE), this is always true and ICSFFE is always high --- In this case, Fixed clock is BUS clock.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2).In ICS Bypass modes, ICSFFE will get asserted for the following combinations of BDIV and RDIV values:&lt;/P&gt;&lt;P&gt;BDIV=00 (divide by 1), RDIV ≥ 010&lt;/P&gt;&lt;P&gt;• BDIV=01 (divide by 2), RDIV ≥ 011&lt;/P&gt;&lt;P&gt;• BDIV=10 (divide by 4), RDIV ≥ 100&lt;/P&gt;&lt;P&gt;• BDIV=11 (divide by 8), RDIV ≥ 101&lt;/P&gt;&lt;P&gt;For example, In FBI mode, ICSOUT = Internal Refrence Clock/ BDIV,&amp;nbsp; and ICSFFCLK = Internal RefrenceClock/RDIV.&amp;nbsp; You can see each BDIV and RDIV combination will result of&amp;nbsp; ICSOUT frequencies four times than the divided FLL reference clock (ICSFFCLK).&lt;/P&gt;&lt;P&gt;In this case, Fixed Clock is also BUS Clock.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other cases, Fixed Clock is ICSFFCLK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From your code, you application is using FEI mode, right?&amp;nbsp; as above analysis, Fixed clock is BUS clock = 1MHz. other word, MTIM's clock soure is 1MHz.&lt;/P&gt;&lt;P&gt;so we need to recalculate the modulo value. but the maximum delay get from MTIM is 256*256 = 65536us.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I recommend you to use RTI, it can generate 1 s interrupt. for detial, please refer to section 5.7 and section 5.8.7.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope my info is helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;B.R&lt;/P&gt;&lt;P&gt;Weiping&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 08 Apr 2014 08:41:22 GMT</pubDate>
    <dc:creator>weapon</dc:creator>
    <dc:date>2014-04-08T08:41:22Z</dc:date>
    <item>
      <title>MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307287#M20690</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;I'm&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;trying to make a&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;program that&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;after a minute&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;turn off&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;or turn on&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;an LED&lt;/SPAN&gt;. &lt;BR /&gt;&lt;SPAN class="hps"&gt;With an&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;8-bit timer&lt;/SPAN&gt; I want to &lt;SPAN class="hps"&gt;produce&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;a delay of one&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;second.&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;As I&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;want to make a&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;1 minute&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;delay&lt;/SPAN&gt; , I &lt;SPAN class="hps"&gt;introduce&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;this function&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;within&lt;/SPAN&gt; a for loop,&lt;SPAN class="hps"&gt;to count&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="hps"&gt;60 seconds.&lt;/SPAN&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;The&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;system&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;clock&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;configuration&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;is:&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hps"&gt; &lt;SPAN class="hps"&gt;internal&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;clock frequency&lt;/SPAN&gt;: &lt;SPAN class="hps"&gt;31.25&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;kHz&lt;/SPAN&gt; &lt;BR /&gt;&lt;SPAN class="hps"&gt;bus frequency&lt;/SPAN&gt;&lt;SPAN&gt;: 1MHz&lt;/SPAN&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;The timer setting&lt;/SPAN&gt; &lt;SPAN class="atn hps"&gt;(&lt;/SPAN&gt;MTIM) &lt;BR /&gt;&lt;SPAN class="hps"&gt;Clock source&lt;/SPAN&gt;&lt;SPAN&gt;: fixed&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;clock&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;frecuency&lt;/SPAN&gt;, &lt;SPAN class="hps"&gt;is supposed to be&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;15625&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;Hz&lt;/SPAN&gt; (I don't&lt;SPAN lang="en"&gt;&lt;SPAN title="Fuente de reloj: fixed frecuency clock, se supone que es 15625 Hz( no elijo La frecuencia del bus porque es demasiado grande) "&gt; choose bus frequency because it is too large)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;Prescaler&lt;/SPAN&gt;: &lt;SPAN class="hps"&gt;128&lt;/SPAN&gt; &lt;BR /&gt;&lt;SPAN class="hps"&gt;Module:&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;123&lt;/SPAN&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;With this configuration,&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the program&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;did not&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;work&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;well&lt;/SPAN&gt;. &lt;SPAN class="hps"&gt;The&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;delay1s&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;() function&lt;/SPAN&gt; do not &lt;SPAN class="hps"&gt;produces&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;a delay of&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;one second,&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;in fact,&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;much&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;less time and&lt;/SPAN&gt; I &lt;SPAN class="hps"&gt;do not understand&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;that,&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;because if&lt;/SPAN&gt;: &lt;BR /&gt;&lt;SPAN class="hps"&gt;fixed&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;clock&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;frecuency&lt;/SPAN&gt;, &lt;SPAN class="hps"&gt;is supposed to&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;15625Hz&lt;/SPAN&gt; &lt;BR /&gt;&lt;SPAN class="hps"&gt;T =&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;1/15625&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;=&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;64us&lt;/SPAN&gt; &lt;BR /&gt;&lt;SPAN class="hps"&gt;64us&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;*&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;128 =&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;8,192&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;ms&lt;/SPAN&gt; &lt;BR /&gt;&lt;SPAN class="hps"&gt;9,192&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;ms *&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;123 =&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;1.007616&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="hps"&gt;&lt;SPAN class="hps"&gt;&lt;/SPAN&gt; &lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;MC9S08QG8&lt;/SPAN&gt; :&lt;A _jive_internal="true" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.freescale.com%2Ffiles%2Fmicrocontrollers%2Fdoc%2Fdata_sheet%2FMC9S08QG8.pdf" rel="nofollow" target="_blank"&gt;http://www.freescale.com/files/microcontrollers/doc/data_sheet/MC9S08QG8.pdf&lt;/A&gt;&lt;BR /&gt;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="¿Quizás la frecuencia fija de reloj(fixed frecuency clock) no es la que yo pensaba?¿En ese caso cuál sería?   "&gt;Perhaps fixed clock frequency ( clock frecuency fixed ) is not what I thought ? Then what would ?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;Does anyone know&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;why the program&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;did not&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;work well&lt;/SPAN&gt;? &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;SPAN lang="en"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="El código es el siguiente: "&gt;The code is as follows :&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="El código es el siguiente: "&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;#include &amp;lt;hidef.h&amp;gt; /* for EnableInterrupts macro */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;#include "derivative.h" /* include peripheral declarations */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;void MCU_init(void){ /* Device initialization function declaration */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; SOPT1=0x00;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; SOPT2=0x00;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; ICSC1=0x04; //SETTINGS INTERNAL CLOCK SOURCE&amp;nbsp; INTERNAL REFERENCE FRECUENCY=31.25kHz&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; ICSC2=0xC0;&amp;nbsp; //SETTINGS INTERNAL CLOCK SOURCE BDIV=11 0x08&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; ICSTRM = *(unsigned char*)0xFFAF;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initialize ICSTRM register from a non volatile memory */&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; ICSSC = *(unsigned char*)0xFFAE;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Initialize ICSSC register from a non volatile memory */&amp;nbsp;&amp;nbsp; //frec bus =1MHz&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;void MTIM_init(){&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MTIMSC=0x10;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MTIMCLK=0x17;&amp;nbsp;&amp;nbsp;&amp;nbsp; // CLKS= Fixed frecuency clock&amp;nbsp; PS=128&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MTIMSC_TRST=0;&amp;nbsp;&amp;nbsp; //Fixed frecuency clock suposes to be (INTERNAL REFERENCE FRECUENCY/2)=15,625kHz&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;void&amp;nbsp; end1s(){&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // function to clear overflow flag&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; char aux= MTIMSC;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; MTIMSC_TOF=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; MTIMSC_TSTP=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;void delay1s(){&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; MTIMMOD=122;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; MTIMSC_TSTP=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; while(MTIMSC_TOF==0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; end1s();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;void main(void) {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i=0;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTBDD_PTBDD7=1;&amp;nbsp;&amp;nbsp; // lED&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PTBD_PTBD7=0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TURN OFF LED&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp; MCU_init(); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp; MTIM_init();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; EnableInterrupts; /* enable interrupts */&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; for(i=0;i&amp;lt;60;i++)&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay1s();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp; PTBD_PTBD7=1;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TURN ON LED&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;60;i++)&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay1s();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; PTBD_PTBD7=0;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TURN OFF LED&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; for(i=0;i&amp;lt;60;i++)&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delay1s();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; PTBD_PTBD7=1;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TURN ON LED&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Mar 2014 20:06:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307287#M20690</guid>
      <dc:creator>marmor</dc:creator>
      <dc:date>2014-03-31T20:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307288#M20691</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Maria,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As your setting, ICSFFCLK(Fixed clock freq) is 31.25KHz, I attached one picture to show you the clock path of ICSFFCLK, which is the divieded FLL reference clock.&amp;nbsp; please try to double your modulo of MTIM.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="ICSFFCLK.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/43380iB3679CD4C7AD09A8/image-size/large?v=v2&amp;amp;px=999" role="button" title="ICSFFCLK.jpg" alt="ICSFFCLK.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;B.R&lt;/P&gt;&lt;P&gt;Weiping&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Apr 2014 06:52:46 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307288#M20691</guid>
      <dc:creator>weapon</dc:creator>
      <dc:date>2014-04-01T06:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307289#M20692</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;Hi&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;Weiping&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;Xu&lt;/SPAN&gt;.&lt;BR /&gt;&lt;BR /&gt; &lt;SPAN class="hps"&gt;I changed&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the module as&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;you said&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;and&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;does not work&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;properly.&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;Before,&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the&lt;/SPAN&gt; for loop with the &lt;SPAN class="hps"&gt;delay1s&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;() function inside &lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN class="hps"&gt;should produce a&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;delay of one minute &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="hps"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;but&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;produces&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;a delay of 6&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;seconds or less&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;and&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;changing the value&lt;/SPAN&gt; &lt;SPAN class="alt-edited hps"&gt;to the double&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;produces a&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;delay of 12&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;seconds or less.&lt;/SPAN&gt;&lt;BR /&gt; &lt;SPAN class="hps"&gt;I do not understand&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;what could be wrong&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Apr 2014 09:15:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307289#M20692</guid>
      <dc:creator>marmor</dc:creator>
      <dc:date>2014-04-01T09:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307290#M20693</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;Another thing&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;I've looked at&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the manual and&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the clock frequency&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;can be&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;ICSFFCLK&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;/ 2 or&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;ICSOUT&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;/ 2,&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;depends on&lt;/SPAN&gt; ICSFFE.&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;The manual&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;also puts&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;this about&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;relj&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;fixed&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;frequency, even&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;I do not understand&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;very well.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;The ICS provides the divided FLL reference clock as ICSFFCLK for use as an additional clock source for&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;peripheral modules. The ICS provides an output signal (ICSFFE) which indicates when the ICS is&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;providing ICSOUT frequencies four times or greater than the divided FLL reference clock (ICSFFCLK).&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;In FLL engaged mode (FEI and FEE), this is always true and ICSFFE is always high. In ICS Bypass&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;modes, ICSFFE will get asserted for the following combinations of BDIV and RDIV values:&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp; BDIV=00 (divide by 1), RDIV ≥ 010&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;• BDIV=01 (divide by 2), RDIV ≥ 011&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;• BDIV=10 (divide by 4), RDIV ≥ 100&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;EM&gt;• BDIV=11 (divide by 8), RDIV ≥ 101&lt;/EM&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="system clock distribution.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/43383iCE1F8693F9FD8C5B/image-size/large?v=v2&amp;amp;px=999" role="button" title="system clock distribution.jpg" alt="system clock distribution.jpg" /&gt;&lt;/span&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Apr 2014 09:26:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307290#M20693</guid>
      <dc:creator>marmor</dc:creator>
      <dc:date>2014-04-01T09:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307291#M20694</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="short_text" lang="en"&gt;&lt;SPAN class="alt-edited hps"&gt;Can anyone help me&lt;/SPAN&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 06 Apr 2014 09:18:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307291#M20694</guid>
      <dc:creator>marmor</dc:creator>
      <dc:date>2014-04-06T09:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307292#M20695</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Maria,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry for late response. Firstly please accept my apology for my wrong answer before. I red those decription about Fixed Clock again, I believe now I can catch the meaning. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1). In FLL engaged mode (FEI and FEE), this is always true and ICSFFE is always high --- In this case, Fixed clock is BUS clock.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2).In ICS Bypass modes, ICSFFE will get asserted for the following combinations of BDIV and RDIV values:&lt;/P&gt;&lt;P&gt;BDIV=00 (divide by 1), RDIV ≥ 010&lt;/P&gt;&lt;P&gt;• BDIV=01 (divide by 2), RDIV ≥ 011&lt;/P&gt;&lt;P&gt;• BDIV=10 (divide by 4), RDIV ≥ 100&lt;/P&gt;&lt;P&gt;• BDIV=11 (divide by 8), RDIV ≥ 101&lt;/P&gt;&lt;P&gt;For example, In FBI mode, ICSOUT = Internal Refrence Clock/ BDIV,&amp;nbsp; and ICSFFCLK = Internal RefrenceClock/RDIV.&amp;nbsp; You can see each BDIV and RDIV combination will result of&amp;nbsp; ICSOUT frequencies four times than the divided FLL reference clock (ICSFFCLK).&lt;/P&gt;&lt;P&gt;In this case, Fixed Clock is also BUS Clock.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Other cases, Fixed Clock is ICSFFCLK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From your code, you application is using FEI mode, right?&amp;nbsp; as above analysis, Fixed clock is BUS clock = 1MHz. other word, MTIM's clock soure is 1MHz.&lt;/P&gt;&lt;P&gt;so we need to recalculate the modulo value. but the maximum delay get from MTIM is 256*256 = 65536us.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I recommend you to use RTI, it can generate 1 s interrupt. for detial, please refer to section 5.7 and section 5.8.7.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope my info is helpful.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;B.R&lt;/P&gt;&lt;P&gt;Weiping&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 08:41:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307292#M20695</guid>
      <dc:creator>weapon</dc:creator>
      <dc:date>2014-04-08T08:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307293#M20696</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Maria,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is my Understanding of ICS&amp;nbsp; Fixed&amp;nbsp; Frequency Clock ( ICSFFCLK)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Actually ICSFFCLK is not 15625 Hz as you mentioned in your code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;31250 Hz (Internal Reference clock) X 512(FLL) = 16000000 Hz= 16MHz / 2 (Default)= 8Mhz &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;8Mhz / 8 (Bdiv) = 1Mhz&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the ICSFFCLK is 1Mhz and Not 15625 Hz.My point is ICSFFCLK is not coming directly from Internal reference source , instant of that after FLL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For reference of ICSFFCLK please see in Attachment AN3041.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 12:47:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307293#M20696</guid>
      <dc:creator>Robinwithu</dc:creator>
      <dc:date>2014-04-08T12:47:01Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307294#M20697</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;Thank you very much&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;for your comments.&lt;/SPAN&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;Now I understand&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;how&lt;/SPAN&gt; &lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;microcontroller &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="alt-edited hps"&gt;clocks&lt;/SPAN&gt;&lt;SPAN lang="en"&gt;&lt;/SPAN&gt; &lt;SPAN class="hps"&gt; &lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;work&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;. &lt;BR /&gt;&lt;SPAN class="hps"&gt;But when&lt;/SPAN&gt; I &lt;SPAN class="hps"&gt;put it &lt;/SPAN&gt; &lt;SPAN class="hps"&gt;into practice&lt;/SPAN&gt;, the counter &lt;SPAN class="alt-edited hps"&gt;still not working correctly&lt;/SPAN&gt;. &lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;With the&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;code I wrote&lt;/SPAN&gt;, &lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;the&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;clock&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;timer&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;I selected&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;was&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the &lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;fixed frequency&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; clock(MTIM_CLKS=01b) &lt;/SPAN&gt;&amp;nbsp; and the &lt;/SPAN&gt;&lt;SPAN class="hps"&gt;fixed frequency&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;clock&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;would&lt;/SPAN&gt; be &lt;SPAN class="hps"&gt;1Mhz&lt;/SPAN&gt;, so &lt;SPAN class="hps"&gt;the for loop&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;should produce a&lt;/SPAN&gt; delay &lt;SPAN class="hps"&gt;of&lt;/SPAN&gt; &lt;SPAN class="atn hps"&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;1/1Mhz&lt;/SPAN&gt;) * 128 * 122 * 60 = 0.93696 &lt;SPAN class="hps"&gt;s&lt;/SPAN&gt; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt; for(i=0;i&amp;lt;60;i++)&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp; delay1s();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: #0000ff;"&gt; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;128 is the&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;timer&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;prescaler&lt;/SPAN&gt;&amp;nbsp; (MTIM_PS=111b)&lt;BR /&gt;&lt;SPAN class="hps"&gt;122&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;is the&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;timer&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;module&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (MTIMMOD=122)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;SPAN class="hps"&gt;60 is&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;i&lt;/SPAN&gt;, the number &lt;SPAN class="hps"&gt;of cycles of the for &lt;/SPAN&gt; &lt;SPAN class="hps"&gt;loop.&lt;/SPAN&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;Knowing this&lt;/SPAN&gt;, why do &lt;SPAN class="hps"&gt;I get&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;a delay of&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;about&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;6s&lt;/SPAN&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Por otro lado, si selecciono como reloj de timer el reloj del bus(MTIM_CLKS=00) y la frecuencia del bus es 1Mhz, el bucle for produce un retardo de menos de 1s, quizás de ms o us ,no lo sé."&gt;Furthermore, if selected as clock timer clock bus ( MTIM_CLKS = 00) and the bus frequency is 1 MHz , the loop produces a delay of less than 1s ,&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Por otro lado, si selecciono como reloj de timer el reloj del bus(MTIM_CLKS=00) y la frecuencia del bus es 1Mhz, el bucle for produce un retardo de menos de 1s, quizás de ms o us ,no lo sé."&gt;perhaps&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; ms or us, do not know . &lt;/SPAN&gt;&lt;SPAN title="Lo que quiero decir es que deberían producir el mismo retardo, ,ya que su frecuencia es la misma, y no lo hacen.   "&gt;What I mean is that both should produce the same delay , since its frequency is the same, and they do not.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="También he probrado a cambiar la frecuencia del bus a 15625Hz:  "&gt;I also try to change the bus frequency to 15625Hz :&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="fbus= 31.25k*512/(2*RDIV*BDIV)=15625Hz.  "&gt;fbus = 31.25k * 512 / (2 * BDIV *Rdiv * ) = 15625Hz .&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="RDIV=64 (ICSC1_RDIV=110b) ICSC1=0x34 "&gt;RDIV = 64 ( ICSC1_RDIV = 110b )&amp;nbsp;&amp;nbsp; ICSC1 = 0x34&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="BDIV=8 (ICSC2_BDIV=11b) ICSC2=0xC0   "&gt;BDIV = 8 ( ICSC2_BDIV = 11b )&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ICSC2 = 0xC0&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="Con esta configuración, si selecciono como reloj de timer el reloj del bus(MTIM_CLKS=00) y el prescaler del timer es 128 y su módulo 122, como antes me debería dar un retraso de (1/15625)*128*122*60"&gt;With this configuration , if selected as clock timer the&amp;nbsp; clock bus ( MTIM_CLKS = 00 ) and the prescaler of the timer is 128 and module 122 ,&amp;nbsp; the for loop should give a delay of (1/15625) * 128 * 122 * 60 &lt;/SPAN&gt;&lt;SPAN title="= 59.96544s "&gt;= 59.96544s&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="60 es i, el número de ciclos del bucle for.  "&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="60 es i, el número de ciclos del bucle for.  "&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="60 es i, el número de ciclos del bucle for.  "&gt;60 is i , the number of cycles of the loop.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="Con esta configuración me sale un retardo de menos de 1 segundo"&gt;With this configuration I get a delay of less than 1 second.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Con esta configuración me sale un retardo de menos de 1 segundo"&gt;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Con esta configuración me sale un retardo de menos de 1 segundo"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="¿Qué esta pasando?"&gt;What's going on ? &lt;/SPAN&gt;&lt;SPAN title="No entiendo que estoy haciendo mal."&gt;Do not understand what I'm doing wrong.&amp;nbsp; :smileysad:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Apr 2014 17:53:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307294#M20697</guid>
      <dc:creator>marmor</dc:creator>
      <dc:date>2014-04-08T17:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307295#M20698</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Maria,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again here i am sending you one Application Note based on "Clock Options on the HC9S08 Family" in which they are saying that&amp;nbsp; "The RDIV bits have no bearing if the internal reference clock is used." on Page number 3 and section 2.1.1under&amp;nbsp; "ICS FLL" first paragraph last line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;it means that RDIV is only for external reference clock in case of ICSFFCLK.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if i will do the calculation for delay which you haven mentioned is as follows :ICSFFCLK Timing is 1µsec (cause freq. is 1Mhz)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Con esta configuración, si selecciono como reloj de timer el reloj del bus(MTIM_CLKS=00) y el prescaler del timer es 128 y su módulo 122, como antes me debería dar un retraso de (1/15625)*128*122*60"&gt; 1µsec * 128 * 122 * 60 &lt;SPAN title="= 59.96544s "&gt;=0.93696 sec&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Con esta configuración, si selecciono como reloj de timer el reloj del bus(MTIM_CLKS=00) y el prescaler del timer es 128 y su módulo 122, como antes me debería dar un retraso de (1/15625)*128*122*60"&gt;&lt;SPAN title="= 59.96544s "&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Con esta configuración, si selecciono como reloj de timer el reloj del bus(MTIM_CLKS=00) y el prescaler del timer es 128 y su módulo 122, como antes me debería dar un retraso de (1/15625)*128*122*60"&gt;&lt;SPAN title="= 59.96544s "&gt;so it's less than 1 sec as you mentioned in your comment.is this the value you are getting ?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Con esta configuración, si selecciono como reloj de timer el reloj del bus(MTIM_CLKS=00) y el prescaler del timer es 128 y su módulo 122, como antes me debería dar un retraso de (1/15625)*128*122*60"&gt;&lt;SPAN title="= 59.96544s "&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Con esta configuración, si selecciono como reloj de timer el reloj del bus(MTIM_CLKS=00) y el prescaler del timer es 128 y su módulo 122, como antes me debería dar un retraso de (1/15625)*128*122*60"&gt;&lt;SPAN title="= 59.96544s "&gt;I hope this will help you.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Con esta configuración, si selecciono como reloj de timer el reloj del bus(MTIM_CLKS=00) y el prescaler del timer es 128 y su módulo 122, como antes me debería dar un retraso de (1/15625)*128*122*60"&gt;&lt;SPAN title="= 59.96544s "&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Con esta configuración, si selecciono como reloj de timer el reloj del bus(MTIM_CLKS=00) y el prescaler del timer es 128 y su módulo 122, como antes me debería dar un retraso de (1/15625)*128*122*60"&gt;&lt;SPAN title="= 59.96544s "&gt;With Best Regards,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Con esta configuración, si selecciono como reloj de timer el reloj del bus(MTIM_CLKS=00) y el prescaler del timer es 128 y su módulo 122, como antes me debería dar un retraso de (1/15625)*128*122*60"&gt;&lt;SPAN title="= 59.96544s "&gt;Robin S&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2014 07:15:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307295#M20698</guid>
      <dc:creator>Robinwithu</dc:creator>
      <dc:date>2014-04-09T07:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307296#M20699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Maria,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just looking at your code and I wonder if the following line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MTIMSC_TRST=0;&amp;nbsp; //Fixed frecuency clock suposes to be (INTERNAL REFERENCE FRECUENCY/2)=15,625kHz&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Should be:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MTIMSC_TRST=1;&amp;nbsp; //Fixed frecuency clock suposes to be (INTERNAL REFERENCE FRECUENCY/2)=15,625kHz&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Also should there be a NOP in the following line to give the MCU chance to successfully update the TOF flag?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while(MTIMSC_TOF==0);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;I also wonder if it's worth stepping back a little and firstly verifying that the BUS clock is running at 1MHz before even considering what the MTIM is doing. You could toggle a pin and use an oscilloscope to measure the time etc. Once this has been ascertained the MTIM could be set to use the verified BUS clock. From this point you can build up until eventually obtaining your 1 second timeout.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Perhaps instead or starting and stopping the MTIM is it better to use the interrupt attached to the module and keep a count of the timeouts?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Hope this helps :-)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Ian&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2014 07:56:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307296#M20699</guid>
      <dc:creator>iansmusical</dc:creator>
      <dc:date>2014-04-09T07:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307297#M20700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P class="almost_half_cell"&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;Thank you very much&lt;/SPAN&gt;. &lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;Yes&lt;/SPAN&gt;, &lt;SPAN class="hps"&gt;that&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;is the value&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;I was getting&lt;/SPAN&gt;&lt;SPAN&gt;, so another&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;question&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;resolved&lt;/SPAN&gt;&lt;SPAN&gt;!&lt;/SPAN&gt;!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2014 08:38:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307297#M20700</guid>
      <dc:creator>marmor</dc:creator>
      <dc:date>2014-04-09T08:38:43Z</dc:date>
    </item>
    <item>
      <title>Re: Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307298#M20701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ian!!&lt;/P&gt;&lt;P&gt;Thanks for your comment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="alt-edited hps"&gt;About what&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;you mentioned&lt;/SPAN&gt; &lt;SPAN class="alt-edited hps"&gt;of the &lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;TRST&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;bit&lt;/SPAN&gt; , &lt;SPAN class="hps"&gt;should be 1&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;to reset&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the account and&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;put the&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;TOF&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;flag&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;to 0,&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;but neither&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;is very important because&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;when writing&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;MTIMMOD&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;(the&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;module)&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the previous account&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;is reset&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;and the flag&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;is cleared&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;TOF&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="alt-edited hps"&gt;About&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the while loop&lt;/SPAN&gt;, &lt;SPAN class="hps"&gt;what it does is&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;cause&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;a pause&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;until the&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;TOF&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;flag&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;is set to 1&lt;/SPAN&gt;, &lt;SPAN class="hps"&gt;then pass&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;to the function&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;end1s&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;to clean&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;TOF&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;(which&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;could&lt;/SPAN&gt; &lt;SPAN class="alt-edited hps"&gt;inserting this code&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;in&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the interrupt that&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;corresponds&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;to the timer&lt;/SPAN&gt;). &lt;SPAN class="hps"&gt;I&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;I think that&lt;/SPAN&gt;&lt;SPAN&gt;'s fine.&lt;/SPAN&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;Anyway&lt;/SPAN&gt;, you're right, I'll try &lt;SPAN class="hps"&gt;with the oscilloscope&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;to get rid&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;of the doubts&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2014 08:57:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307298#M20701</guid>
      <dc:creator>marmor</dc:creator>
      <dc:date>2014-04-09T08:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307299#M20702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Maria,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I simulated your code and the following result i found on Simulation :After Initialization of your Micro controller function &amp;amp; Timer Module&amp;nbsp; setting when your code reach the following&amp;nbsp; function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;void delay1s()&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;int k =MTIMCNT;&lt;/P&gt;&lt;P&gt;&amp;nbsp; MTIMMOD=122;&lt;/P&gt;&lt;P&gt;&amp;nbsp; MTIMSC_TSTP=0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;STRONG&gt;while(MTIMSC_TOF==0);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; end1s();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;at this line&amp;nbsp; &lt;STRONG&gt;while(MTIMSC_TOF==0);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I read total cycles counter ( in PEmicro Simulator tool) and it is 1007580 cycles , So as in your code we have 1Mhz clock which means 1µsec for each cycle .&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;1007580&amp;nbsp; X 1 = &lt;STRONG&gt;1007580 µsec / 1000000 = 1.007580 sec which means 1 sec after first overflow and 60 x 1= 60 sec.&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;After 60 times in for loop&amp;nbsp; ,&amp;nbsp; i am getting 60456925 cycles After simulation.&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;My point is i am getting the expected result in simulation.&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;one more point :&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;for(i=0;i&amp;lt;60;i++) { delay1s();&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; PTBD_PTBD7=1;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TURN ON LED&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;60;i++)&amp;nbsp; {&amp;nbsp; delay1s(); }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTBD_PTBD7=0;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TURN OFF LED&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(i=0;i&amp;lt;60;i++) { delay1s();}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTBD_PTBD7=1;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TURN ON LED&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;here you can also write&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for(;;)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // it's&amp;nbsp; a forever loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;for(i=0;i&amp;lt;60;i++) { delay1s();&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; PTBD_PTBD7=1;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TURN ON LED&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; for(i=0;i&amp;lt;60;i++)&amp;nbsp; {&amp;nbsp; delay1s(); }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; PTBD_PTBD7=0;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TURN OFF LED&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so you don't need to write ON and OFF again and again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;one more thing , in Simulation i am not able to read&amp;nbsp; MTIMCNT register it is always at 0x0000 ; do not know why it's not updating after every count, may be Simulator problem or update function not available.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this answer will help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 08:20:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307299#M20702</guid>
      <dc:creator>Robinwithu</dc:creator>
      <dc:date>2014-04-10T08:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307300#M20703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN title="Hola. "&gt;Hello.&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="He estado midiendo,con un osciloscopio, la frecuencia que usa el temporizador,configurando este con la frecuencia del bus y con la fixed frecuency.  "&gt;I have been measuring with an oscilloscope , the frequency that timer uses, setting this with&amp;nbsp; the &lt;SPAN lang="en"&gt;&lt;SPAN title="He estado midiendo,con un osciloscopio, la frecuencia que usa el temporizador,configurando este con la frecuencia del bus y con la fixed frecuency.  "&gt;bus &lt;/SPAN&gt;&lt;/SPAN&gt;frequency&amp;nbsp; and the &lt;SPAN lang="en"&gt;&lt;SPAN title="He estado midiendo,con un osciloscopio, la frecuencia que usa el temporizador,configurando este con la frecuencia del bus y con la fixed frecuency.  "&gt;fixed&lt;/SPAN&gt;&lt;/SPAN&gt; frecuency .&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="Cuando configuraba el reloj del temporizador para que fuese el reloj del bus me salía aproximadamente 1Mhz. "&gt;When I configured clock timer with the clock bus &lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;I&lt;/SPAN&gt; &lt;SPAN class="alt-edited hps"&gt;obtained&lt;/SPAN&gt; &lt;/SPAN&gt; about 1Mhz .&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="Cuando configuraba el reloj del temporizador para que fuese el reloj de frecuencia fija me salía aproximadamente 15KHz.  "&gt;When &lt;SPAN lang="en"&gt;&lt;SPAN title="Cuando configuraba el reloj del temporizador para que fuese el reloj del bus me salía aproximadamente 1Mhz. "&gt;I configured &lt;/SPAN&gt;&lt;/SPAN&gt;the timer clock to be the fixed frequency clock &lt;SPAN lang="en"&gt;&lt;SPAN title="Cuando configuraba el reloj del temporizador para que fuese el reloj del bus me salía aproximadamente 1Mhz. "&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;I&lt;/SPAN&gt; &lt;SPAN class="alt-edited hps"&gt;obtained &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;about 15KHz .&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="No sé por qué cuando simulaba el código no me salían los mismos resultados que cuando lo he probado en el microcontroller.Cuando he probado el programa en el micro, ha funcionado bien,  "&gt;I do not know why, whenI simulated the code I did not obtain&amp;nbsp; the same results as when I tested it in the microcontroller. When I run the program in the micro, it worked right.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="Conclusiones que he obtenido de la práctica: "&gt;Conclusions I have obtained from practice:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="Con el modo FEI el reloj de frecuencia fija ICSFFCLK es aproximadamente 15625Hz. "&gt;With the FEI mode the&amp;nbsp; fixed frequency&lt;SPAN lang="en"&gt;&lt;SPAN title="Con el modo FEI el reloj de frecuencia fija ICSFFCLK es aproximadamente 15625Hz. "&gt;&lt;/SPAN&gt;&lt;/SPAN&gt; clock &lt;SPAN lang="en"&gt;&lt;SPAN title="Con el modo FEI el reloj de frecuencia fija ICSFFCLK es aproximadamente 15625Hz. "&gt;(&lt;SPAN lang="en"&gt;&lt;SPAN title="Con el modo FEI el reloj de frecuencia fija ICSFFCLK es aproximadamente 15625Hz. "&gt; ICSFFCLK) &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;is approximately 15625Hz .&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="Si seleccionas el reloj de frecuencia fija como reloj del temporizador su frecuencia será aproximadamente 15625Hz. "&gt;If you select the fixed frequency clock as the timer clock, frequency will be about 15625Hz .&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="Si seleccionas el reloj del bus como reloj del temporizador su frecuencia será aproximadamente 1Mhz ( en este caso).  "&gt;Selecting the bus clock as the timer clock, frequency &lt;SPAN lang="en"&gt;&lt;SPAN title="Si seleccionas el reloj de frecuencia fija como reloj del temporizador su frecuencia será aproximadamente 15625Hz. "&gt; will be&lt;/SPAN&gt;&lt;/SPAN&gt; about 1 MHz ( in this case) .&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN title="Quería daros las gracias a todos por vuestros comentarios y por ayudarme."&gt;I wanted to thank you all for your comments and help .&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 19:56:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307300#M20703</guid>
      <dc:creator>marmor</dc:creator>
      <dc:date>2014-04-10T19:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307301#M20704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;Hello&lt;/SPAN&gt; &lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class="hps"&gt;Thank you&lt;/SPAN&gt; for &lt;SPAN class="hps"&gt;taking the time&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;to simulate&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the code.&lt;/SPAN&gt; &lt;BR /&gt;&lt;SPAN class="hps"&gt;You're right,&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;it works as expected&lt;/SPAN&gt;,I don't&amp;nbsp; &lt;SPAN class="hps"&gt;know why&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;the simulation&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;was not working&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;me right.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Apr 2014 20:00:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307301#M20704</guid>
      <dc:creator>marmor</dc:creator>
      <dc:date>2014-04-10T20:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: MC9S08QG8 : Problem with a timer.</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307302#M20705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Maria,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You are welcome and Happy Programming :smileyhappy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;/P&gt;&lt;P&gt;Robin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Apr 2014 06:30:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/MC9S08QG8-Problem-with-a-timer/m-p/307302#M20705</guid>
      <dc:creator>Robinwithu</dc:creator>
      <dc:date>2014-04-11T06:30:32Z</dc:date>
    </item>
  </channel>
</rss>

