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.

Setting the GIE bit in the Status Register

I have tried several methods attempting to set the GIE bit in the SR, none have born fruit.  __enable_interrupt();  __bis_SR_register(GIE);  I also tried  __bis_SR_register(LPM0_bits | GIE);  My timer interrupt never happens and when I stop the program I look at the Core Registers -> SR->GIE and it is 0.  Any ideas of what I am doing wrong????

  • Why don't you simply check proven to work timer source code examples and see how things shall be done?

    Examples for msp430g2553 of launchpad

  • That is a good idea.  In fact I thought of that as I laid my head down for sleep.  I will be trying that now that I can think again.

    Thanks for the suggestion.

  • Well I tried many of the examples with timer interrupts and yes they all work.  I tried to emulate the code in my code and no deal.  I never enter the interrupt.  It might be the header or something.  Here is what I have for the timer and the interrupt:

    TA0CTL |= ID_2; /*Timer0A input divider: 2 - /4 */
    TA0CCR0 = 5000 - 1; /*PWM Period */
    TA0CCTL1 = OUTMOD_7; // CCR1 reset/set
    TA0CCR1 = 750; // CCR1 PWM duty cycle
    TA0CCTL2 = OUTMOD_7; // CCR2 reset/set
    TA0CCR2 = 250; // CCR2 PWM duty cycle
    TA0CTL |= TASSEL__SMCLK; /*Timer0A clock source select:SMCLK */
    TA0CTL |= TACLR; /*Timer0A counter clear */
    TA0CTL |= MC__UP; /*Up mode-Timer counts up to TA0CCR0*/
    TA0CTL |= TAIE; /*Timer A counter interrupt enable */

    //------------------------------------------------------------------------------
    // Timer1 A0 Interrupt Service Routine
    //------------------------------------------------------------------------------
    #pragma vector=TIMER0_A0_VECTOR
    __interrupt void TIMER0_A0_ISR(void)
    {
    if((P4IN &= BIT5) == 0) {
    P4OUT |= BIT6;
    if(TA0CCR1 >= 50) TA0CCR1 -= 50;
    else TA0CCR1 = 0;
    }
    else P4OUT &= ~BIT6;
    }

    Anyone got any suggestions?

  • SAB said:
    I tried to emulate the code in my code and no deal.

    "No deal" does not give any meaningful information about your results and how you check them. Also it would be good to know what exactly you are trying to achieve.

    Don't try everything at once because then you will not notice what you are actually doing wrong.  Modify example code by steps, verify after each step.

  • You did not set the CCIE bit inside the TA0CCTL0 register. Thus your TIMER0_A0_ISR() will not be invoked.

    I do not know if the GIE bit in SR was set or not. If not, the said ISR will not be invoked either. Instead, the TAIE bit in your TA0CTL register might cause your code to crash, because you do not seem to have an ISR for TAIE interrupt. You may be lucky because your code might have fallen off the end of your code before it crashes.
  • Sorry for using the colloquialism. I did not try everything at once. I made a change, tested, traced code, scratched head (sorry another colloquialism), then I went on and tried something else that I found in the sample code. None of which worked.
  • Now in reading the MSP430FR5XXX User Guide, it was my understanding that the CCIE bit is used for counter/compare. I need an interrupt when the counter resets. I guess I misunderstood what the CCIE and the TAIE do. It is my understanding that TAIE is for the counter reset. I use the __bis_SR_register(LPM3_bits | GIE) to set the global interrupt which I verified that it did in fact do. I am going to try the CCIE bit instead of the TAIE and see what happens. Thanks for the suggestion.
  • I did not say that you need to use CCIE. What I meant was, given that you did not set CCIE you do not need the ISR you included. If will not be invoked.

    I did not say that you shouldn't use TAIE. What I meant was, given that you did set TAIE you do need to provide a different ISR. You did not provide that ISR, thus your code will crash when TAIE triggers an interrupt.

    CCIE and TAIE generate different interrupts and need different ISRs.
  • Maybe reading this will give you some more information:

    http://e2e.ti.com/support/microcontrollers/msp430/f/166/p/381874/1346638#1346638

    Dennis
  • You’re right, TAIE is for the timer reset (or rather, the timer overflow) interrupt. However, the timer overflow interrupt, as well as the capture/compare interrupts (CCIE) for CCR1-x, are handled in the TIMERx_A1_VECTOR.
    The TIMERx_A0_VECTOR is exclusively for the CCR0 interrupt.
    Note that for the TIMERx_A1_VECTOR ISR, you need to clear the IFG bit that caused the interrupt (or the ISR gets called over and over again). You also need to check these bits in order to see which interrupt called your ISR (of course, if you only have enabled one, then it must have been this one)
    You can read TAxIV to get the interrupt number and at the same time clear the IFG bit.
  • That link helped a lot. I am going to try this after I complete some assignments that where dropped on my desk.
  • Thanks for the explanation. I made the changes to the code and sure enough, it works! Thanks for all your help. I am going to have to re-read, again, the timer section of the family user's guide.

**Attention** This is a public forum