Timer and SCI Interrupts problems - MC9S08SH

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Timer and SCI Interrupts problems - MC9S08SH

602 Views
CarlosCba
Contributor II

Hi,

I have implemented a timer interrupt and the receive SCI interrupt, it has a 4MHz external oscillator and the watchdog is disable.

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.

void Timer_Init(void){     MTIMCLK_CLKS0 = 0; //Clock Source : BUSCLK   MTIMCLK_CLKS1 = 0;   MTIMCLK_PS0 = 1; //Prescaler: %32   MTIMCLK_PS1 = 0;   MTIMCLK_PS2 = 1;   MTIMCLK_PS3 = 0;   MTIMMOD = 0x07;    MTIMSC_TOIE = 1; //Habilitamos Interrupción   MTIMSC_TSTP = 1; //Timer OFF    RegOnTimerLedsISR(ParpadeoLeds); }  /**********************************/ /* Frequency of the leds          */ /**********************************/ void ParpadeoLeds(void) {   static unsigned int mushintIndice = 0;    mushintIndice++;    if ( (guchParpaLed == LED_OFF) && (mushintIndice == 3906) ) // slow blink   {   Flash_Led_Activity; // toggle led   mushintIndice = 0;   }else if ( (guchParpaLed == LED_ON) && (mushintIndice == 1953) ) // fast blink   {   Flash_Led_Activity; //toggle led   mushintIndice = 0;   } }  /************************************************************/ /* Registro del puntero a función del Timer en la ISR       */ /************************************************************/ void RegOnTimerLedsISR(ptrInterruptTimer ptrTimer) {   ptrTimerISR = ptrTimer; } Pragma TRAP_PROC void Timer_ISR(void) {   MTIMSC_TOF = 0; //Borramos la bandera   MTIMSC_TOIE = 1; //Habilitamos la Interrupción    if(ptrTimerISR)   ptrTimerISR(); }  // if(ptrRecepcionBytesSCI) // ptrRecepcionBytesSCI(); }

 

The SCI interrupt is working at 9600 baud, once I receive a char from the serial it activate a state machine (switch-case).

Problem: When I received a char the timer interrupt stop working  and the microcontroller hang. 

I attached a video.

 

 

All yours reply help me to much.

Thanks in advance.

Best regards,

Carlos.

Labels (1)
0 Kudos
1 Reply

365 Views
CarlosCba
Contributor II

I forget to say that the serial communication is RS485 with SN75176 (TI).

0 Kudos