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.

How to property disable a timer?


I am trying to interface a buzzer to MSP430F67xx. A transistor is installed between Pin4.7 and the buzzer. The buzzer will ring continuously when turned on. So I feel I can use one of the timers to generate a non-continuous ringing to save some power. I am having some trouble to turn off the buzzer. The following is my code:

#include "io430.h"
void buzzer(char tag, int duration);
int main( void )
  // Stop watchdog timer to prevent time out reset
  P4SEL &= ~BIT7;
  P4DIR |= BIT7;
  P4OUT &= ~BIT7;

  buzzer(1, 10000);

  //setup interupt port turn off buzzer
  P1IES |= BIT7;
  P1IFG &= ~BIT7;
  P1IE |= BIT7;

  __bis_SR_register(LPM3_bits | GIE);     // Enter LPM3 w/ interrupts

  return 0;

void buzzer(char tag, int duration)
          TA1CCTL0 |= CCIE;                        // CCR0 interrupt enabled
          TA1CCR0 = duration;
          TA1CTL = TASSEL_1 | MC_1 | TACLR;       // ACLK, up mode, clear TAR
          TA1CCTL0 &= ~ CCIE;
          TA1CTL |= MC_0;
          P4OUT &= ~BIT7;

#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
    P4OUT ^= BIT7;                          // Toggle P4.7

#pragma vector = PORT1_VECTOR
__interrupt void P1_ISR(void)
  if (P1IFG & BIT7)

If I don't include the highlighted line of code in my buzzer function. I can still hear some low level non-continuous noise coming out of buzzer after I push a button connected to P1.7. If I do include that line of code, basically disable TA1 interrupt, then that low level noise will go.

This is not a problem per se, but I am do want to understand why the above happens.


**Attention** This is a public forum