Other Parts Discussed in Thread: MSP430WARE,
Hi. I'm writing a program that should turn on and off a DC-DC converter through a push button on MSP430F5529LP. The button is associated with an interrupt routine. The PWM control function is executed within the TIMER_A5 ISR. My idea is to pause and start the timer from within the button's ISR. At startup the timer counter does not start automatically, the MSP gets LPM0, so I press the button and its ISR runs, Timer_A_startCounter() triggers the timer, and the ISR of the timer runs.
The problem is that pressing the button again does not bring the execution to the ISR of the button in order to turn the converter off. My error is in handling the interrupts. I don't know if it's a matter of priority.
Below is the code from which I removed some parts to facilitate your analysis.
Thank you.
int main(void) { // lots of initialiation and DRV code.... // Enable interrupts globally __enable_interrupt(); //Enter LPM0, enable interrupts __bis_SR_register(LPM0_bits + GIE); __no_operation(); while(1) { __bis_SR_register(LPM0_bits + GIE); // Enter LPM0 and wait for an interrupt __no_operation(); }; } #pragma vector=TIMER0_A1_VECTOR // Timer0_A5 CC1-4, TA __interrupt #elif defined(__GNUC__) __attribute__((interrupt(TIMER0_A0_VECTOR))) #endif void TIMER0_A1_ISR(void) { //Any access, read or write, of the TAIV register automatically resets the //highest "pending" interrupt flag switch(__even_in_range(TA0IV,14)) { case 0: break; //No interrupt case 2: break; //CCR1 not used case 4: break; //CCR2 not used case 6: break; //CCR3 not used case 8: break; //CCR4 not used case 10: break; //CCR5 not used case 12: break; //CCR6 not used case 14: moduladorPWM(); __bic_SR_register_on_exit(LPM0_bits + GIE); break; default: break; } } #pragma vector=BUTTON1_VECTOR __interrupt void Button1_ISR (void) { WORD i; if (GPIO_getInterruptStatus (BUTTON1_PORT, BUTTON1_PIN)){ for (i = 0x23FF; i > 0; i--){ //Cheap debounce. } if (GPIO_getInputPinValue(BUTTON1_PORT, BUTTON1_PIN)){ bButton1Pressed = TRUE; } } // Turn on Timer_A_startCounter(TIMER_A0_BASE,TIMER_A_UPDOWN_MODE); // Liga o Led 2 Verde - porta 4.7 GPIO_setOutputHighOnPin(4,0x80); // Enable DRV - MSP4305529LP P2.6 output-low GPIO_setOutputHighOnPin(2,0x40); // Turn off // Flag treatment // Timer_A_stop(TIMER_A0_BASE); GPIO_clearInterrupt(BUTTON1_PORT, BUTTON1_PIN); __bic_SR_register_on_exit(LPM0_bits + GIE); //Wake main from LPMx }