<?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 Timer and SCI Interrupts problems - MC9S08SH in 8-bit Microcontrollers</title>
    <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Timer-and-SCI-Interrupts-problems-MC9S08SH/m-p/252490#M19847</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have implemented a timer interrupt and the receive SCI interrupt, it has a 4MHz external oscillator and the watchdog is disable.&lt;/P&gt;&lt;P&gt;The timer interrupt is configured to jump every 10uSeg, with the prescaler in 2 and MOD = 0x10. Into this interrupt I point to a function where I count up to 3906 to has an approximate time of 500mSeg or to 1953 to has the middle of that time, then I just toogle a led.&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;void Timer_Init(void){&amp;nbsp;&amp;nbsp; &amp;nbsp; MTIMCLK_CLKS0 = 0; //Clock Source : BUSCLK &amp;nbsp; MTIMCLK_CLKS1 = 0; &amp;nbsp; MTIMCLK_PS0 = 1; //Prescaler: %32 &amp;nbsp; MTIMCLK_PS1 = 0; &amp;nbsp; MTIMCLK_PS2 = 1; &amp;nbsp; MTIMCLK_PS3 = 0; &amp;nbsp; MTIMMOD = 0x07;&amp;nbsp; &amp;nbsp; MTIMSC_TOIE = 1; //Habilitamos Interrupción &amp;nbsp; MTIMSC_TSTP = 1; //Timer OFF&amp;nbsp; &amp;nbsp; RegOnTimerLedsISR(ParpadeoLeds); }&amp;nbsp; /**********************************/ /* Frequency of the leds&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */ /**********************************/ void ParpadeoLeds(void) { &amp;nbsp; static unsigned int mushintIndice = 0;&amp;nbsp; &amp;nbsp; mushintIndice++;&amp;nbsp; &amp;nbsp; if ( (guchParpaLed == LED_OFF) &amp;amp;&amp;amp; (mushintIndice == 3906) ) // slow blink &amp;nbsp; { &amp;nbsp; Flash_Led_Activity; // toggle led &amp;nbsp; mushintIndice = 0; &amp;nbsp; }else if ( (guchParpaLed == LED_ON) &amp;amp;&amp;amp; (mushintIndice == 1953) ) // fast blink &amp;nbsp; { &amp;nbsp; Flash_Led_Activity; //toggle led &amp;nbsp; mushintIndice = 0; &amp;nbsp; } }&amp;nbsp; /************************************************************/ /* Registro del puntero a función del Timer en la ISR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */ /************************************************************/ void RegOnTimerLedsISR(ptrInterruptTimer ptrTimer) { &amp;nbsp; ptrTimerISR = ptrTimer; } Pragma TRAP_PROC void Timer_ISR(void) { &amp;nbsp; MTIMSC_TOF = 0; //Borramos la bandera &amp;nbsp; MTIMSC_TOIE = 1; //Habilitamos la Interrupción&amp;nbsp; &amp;nbsp; if(ptrTimerISR) &amp;nbsp; ptrTimerISR(); }&amp;nbsp; // if(ptrRecepcionBytesSCI) // ptrRecepcionBytesSCI(); }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SCI interrupt is working at 9600 baud, once I receive a char from the serial it activate a state machine (switch-case).&lt;/P&gt;&lt;P&gt;Problem: When I received a char the timer interrupt stop working&amp;nbsp; and the microcontroller hang.&amp;nbsp; &lt;/P&gt;&lt;P&gt;I attached a video.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All yours reply help me to much.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Carlos.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Dec 2013 22:26:29 GMT</pubDate>
    <dc:creator>CarlosCba</dc:creator>
    <dc:date>2013-12-09T22:26:29Z</dc:date>
    <item>
      <title>Timer and SCI Interrupts problems - MC9S08SH</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Timer-and-SCI-Interrupts-problems-MC9S08SH/m-p/252490#M19847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have implemented a timer interrupt and the receive SCI interrupt, it has a 4MHz external oscillator and the watchdog is disable.&lt;/P&gt;&lt;P&gt;The timer interrupt is configured to jump every 10uSeg, with the prescaler in 2 and MOD = 0x10. Into this interrupt I point to a function where I count up to 3906 to has an approximate time of 500mSeg or to 1953 to has the middle of that time, then I just toogle a led.&lt;/P&gt;&lt;PRE class="c++" name="code"&gt;void Timer_Init(void){&amp;nbsp;&amp;nbsp; &amp;nbsp; MTIMCLK_CLKS0 = 0; //Clock Source : BUSCLK &amp;nbsp; MTIMCLK_CLKS1 = 0; &amp;nbsp; MTIMCLK_PS0 = 1; //Prescaler: %32 &amp;nbsp; MTIMCLK_PS1 = 0; &amp;nbsp; MTIMCLK_PS2 = 1; &amp;nbsp; MTIMCLK_PS3 = 0; &amp;nbsp; MTIMMOD = 0x07;&amp;nbsp; &amp;nbsp; MTIMSC_TOIE = 1; //Habilitamos Interrupción &amp;nbsp; MTIMSC_TSTP = 1; //Timer OFF&amp;nbsp; &amp;nbsp; RegOnTimerLedsISR(ParpadeoLeds); }&amp;nbsp; /**********************************/ /* Frequency of the leds&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */ /**********************************/ void ParpadeoLeds(void) { &amp;nbsp; static unsigned int mushintIndice = 0;&amp;nbsp; &amp;nbsp; mushintIndice++;&amp;nbsp; &amp;nbsp; if ( (guchParpaLed == LED_OFF) &amp;amp;&amp;amp; (mushintIndice == 3906) ) // slow blink &amp;nbsp; { &amp;nbsp; Flash_Led_Activity; // toggle led &amp;nbsp; mushintIndice = 0; &amp;nbsp; }else if ( (guchParpaLed == LED_ON) &amp;amp;&amp;amp; (mushintIndice == 1953) ) // fast blink &amp;nbsp; { &amp;nbsp; Flash_Led_Activity; //toggle led &amp;nbsp; mushintIndice = 0; &amp;nbsp; } }&amp;nbsp; /************************************************************/ /* Registro del puntero a función del Timer en la ISR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */ /************************************************************/ void RegOnTimerLedsISR(ptrInterruptTimer ptrTimer) { &amp;nbsp; ptrTimerISR = ptrTimer; } Pragma TRAP_PROC void Timer_ISR(void) { &amp;nbsp; MTIMSC_TOF = 0; //Borramos la bandera &amp;nbsp; MTIMSC_TOIE = 1; //Habilitamos la Interrupción&amp;nbsp; &amp;nbsp; if(ptrTimerISR) &amp;nbsp; ptrTimerISR(); }&amp;nbsp; // if(ptrRecepcionBytesSCI) // ptrRecepcionBytesSCI(); }&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SCI interrupt is working at 9600 baud, once I receive a char from the serial it activate a state machine (switch-case).&lt;/P&gt;&lt;P&gt;Problem: When I received a char the timer interrupt stop working&amp;nbsp; and the microcontroller hang.&amp;nbsp; &lt;/P&gt;&lt;P&gt;I attached a video.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All yours reply help me to much.&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Carlos.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Dec 2013 22:26:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Timer-and-SCI-Interrupts-problems-MC9S08SH/m-p/252490#M19847</guid>
      <dc:creator>CarlosCba</dc:creator>
      <dc:date>2013-12-09T22:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Timer and SCI Interrupts problems - MC9S08SH</title>
      <link>https://community.nxp.com/t5/8-bit-Microcontrollers/Timer-and-SCI-Interrupts-problems-MC9S08SH/m-p/252491#M19848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I forget to say that the serial communication is RS485 with SN75176 (TI).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Dec 2013 22:28:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/8-bit-Microcontrollers/Timer-and-SCI-Interrupts-problems-MC9S08SH/m-p/252491#M19848</guid>
      <dc:creator>CarlosCba</dc:creator>
      <dc:date>2013-12-09T22:28:16Z</dc:date>
    </item>
  </channel>
</rss>

