This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Timer1_B3 interrupt problem (MSP-EXP430FR5739)

Hello,

In my program I need periodically blinking led.

I downloaded the WiFiServerApplication from the TI site. I'm using Timer1_B3 to create interrupt and for led blinking.

void blinkLedTimerInitFunc() // INIT TIMER

{

   TB1CCTL0 &=~CCIE;

   TB1CCR0=2000;

   TB1CTL |=TBSSEL_1 ID_3 MC_1 TBIE TBIFG;

   TB1CCTL0 |=CCIE;

}

// My interrupt:

#pragma vector=TIMER1_B0_VECTOR

__interrupt void TimerB1Test(void)

{

   toggleLed(LED8);

   TB1CCR0  =2000;

}

#pragma vector=TIMER1_B1_VECTOR //without it it's not working

__interrupt void TimerB1Test(void)

{

   // NOTHING HERE

}

Ok. My question:

When I placed the blinkLedTimerInitFunc() function  in file demo.c at line 222 (after unsolisicted_events_timer_init() function), the module connects to the WiFi, runs the webserver, LED8 is blinking, but all other interrupts are not working (I think so, because I tried to enter the web server from my laptop, but with no result).

When I placed the blinkLedTimerInitFunc() function before the main while loop (before line 120 in demo.c), the module connects to the WiFi, LED8 is blinking, but web-server is not running.

When I erased the blinkLedTimerInitFunc() function   - the module conects to the WiFi, runs the webserver and I can enter to the server with my laptop.

Understood for me that the problem is timer definition and interrupts.

Please help me!!

Thanks a lot!

Mike

  • Mike Wise said:
       TB1CTL |=TBSSEL_1 ID_3 MC_1 TBIE TBIFG;

    This line will immediately trigger a TIMER1_B1 interrupt. To get a CCR0 interrupt, it is not necessary to set TBIE (and there is no reason for manually setting TBIFG), as this is for enabling the timer overflow interrupt.

    In your TIMER1_B1 ISR, you do NOT clear the IFG flag that has caused the interrupt. So as soon as you exit the ISR, it is entered again, causing an eternal ISR loop and execution of main code is effectively halted.

    Mike Wise said:
       // NOTHING HERE
    Yes, that's the problem. If you don't have the ISR, the CPU is jumping into the void to handle the interrupt you provoked. But if you don't handle the interrupt in teh ISR, the CPU will call the ISR over and over again. In the first case, the device will reset, in the second case, the device will deadlock. The blinking only works because the TIMER1_B0 interrupt has a higher priority, so it is executed between two of the endless ISR loops.

    If you don't set TBIE (and TBIFG, but that's harmless if TBIE is not set), then the second ISR is not needed at all and the code shoudl work as intended.

    The TIMERx_y0 ISRs are special because they only have one possible interrupt source and auto-clear teh associated IFG bit on ISR entry. That saves you some clock cycles. THi sis the reason why you don't get an endless ISR loop for TIMER1_B0 ISR even though you don't clear the CCIFG bit in it. The only other interrupt that is similar is the ADC10 interrupt. All others have more than one interrupt source and require manually deleting the IFG bits. (Well, not true for reset and NMI, but that's a different story)

**Attention** This is a public forum