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.

MSP430FR5969: MSP430FR5969 Timer B ISR problem

Part Number: MSP430FR5969

Hello, I'm trying to use timer B0 on a MSP430FR5969. Basically I want to use the PWM on PIN P1.4,PIN1.5 and PIN3.4. I want also generate a interrupt every 1ms to do some tasks in the future.

So I have configured the microcontroller, to use the TBIFG. The PWM work if TBIE is disabled, but when I enable the interrupt (TBIE) to generate an interrupt every 1ms, the TBIFG is set but the micro doesn't enter into the interrupt routine.

This is the part of code where i set the timer :

//Timer B0 : PWM


     TB0CTL = TBSSEL__SMCLK |ID__1| MC__UP | TBCLR | TBIE;      // SMCLK, up mode, clear TAR
     TB0EX0 = TBIDEX_7;                                                                   // DIV8 : So timer_CLK = SMCLK/8
     TB0CCR0 =  2000;                                                                       // PWM Period 1kHz/Tick 1ms timer
     TB0CCTL1 = OUTMOD_7;                                                            // P1.4 : CCR1 reset/set
     TB0CCR1 =  500;                                                                         // P1.4 : CCR1 PWM duty cycle
     TB0CCTL2 = OUTMOD_7;                                                           // P1.5 : CCR2 reset/set
     TB0CCR2 =  1000;                                                                      // P1.5 : CCR2 PWM duty cycle
     TB0CCTL3 = OUTMOD_7;                                                          // P3.4 : CCR3 reset/set
     TB0CCR3 =  1500;                                                                      // P3.4 : CCR3 PWM duty cycle

     // INTERRUPTS
     __bis_SR_register(GIE);                                    // Enable interrupts




AND THIS ONE IS THE MAIN :




#include <msp430.h>
#include <string.h>
#include "Setup.h"
#include "Screen_Nextion.h"
#include "Other_functions.h"

int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;    // stop watchdog timer
    

    Setup();


    while(1)
    {

        Send_Data_to_PC("AAA");
        __delay_cycles(32000000);
        Send_Data_to_PC("BBB");
        __delay_cycles(32000000);
    }


}




// Timer0_B0 Interrupt

#pragma vector=TIMER0_B0_VECTOR
__interrupt void TIMER0_B0_ISR(void)
{
  switch(__even_in_range(TB0IV, TB0IV_TBIFG))
  {
    case TB0IV_NONE:            break;
    case TB0IV_TBCCR1:        break;               // CCR1 interrupt
    case TB0IV_TBCCR2:        break;               // CCR2 interrupt
    case TB0IV_TBCCR3:        break;               ///CCR3 interrupt
    case TB0IV_TBCCR4:        break;               // CCR4 interrupt
    case TB0IV_TBCCR5:        break;               // CCR5 interrupt
    case TB0IV_TBCCR6:        break;               // CCR6 interrupt
    case TB0IV_TBIFG:
        P1OUT ^= BIT0;
        break;               // TBIFG interrupt
    default: break;
  }
}


I also tried to use the Capture/compare interrupt (CCIE/CCIFG) instead of the TBIFG interrupt request and all works well.

Thanks
Riccardo



**Attention** This is a public forum