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.
Hi,
I am new to the MSP430 from ARM based controllers, and I'm using the MSP-FET430U40A board with the MSP430FR5xxx 40-Pin FET tool with an MSP430FR5739. I have a very simple program that sets up TimerA0 and TimerA1. Timer A0 outputs a PWM signal on P1.1, and I want to set Timer A1 to trigger an interrupt at some configurable time interval so that I can modify the duty cycle of the PWM signal generated by Timer A0. I cannot for the life of me get any timer interrupt to call. I've read every post and tried all of the suggestions with no success, so I was hoping that someone here could get me on the right track. I'm using Code Composer Studio 6.0.1 to develop the project. This is the code that I have so far:
My Main Function:
#include <msp430.h> #include "Setup.h" #include "MPPT.h" #include "ADCRead.h" int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer int i = 0; Sys_Init(); while (1); }
My Setup function:
void Sys_Init(){ CSCTL0_H = 0xA5; CSCTL1 = DCOFSEL0 + DCOFSEL1; // Set DCO max setting = 8MHz CSCTL2 = SELA__DCOCLK + SELM__DCOCLK + SELS__DCOCLK; // set all clocks to be sourced from DCO CSCTL3 = DIVA__2 + DIVM__2 + DIVS__32; // set all dividers //ACLK is divided by 2 (4MHz), Mclock divided by 2 (4MHz) //SMCLK is divided by 32 (250 kHz) // CSCTL4 = SMCLKOFF; //Turn SMCLK off to save power P1DIR |= BIT0; // P1.0 output P1SEL0 |= BIT0; // P1.0 options select TA0CCR0 = CYCLES_30KHZ; // PWM Period (to get 30 kHz, -> 4MHz/30kHz = 133) TA0CCTL1 = OUTMOD_7 + CCIE; // CCR1 reset/set mode TA0CCR1 = 66; // CCR1 PWM duty cycle (50% of value in TA0CCR0 is half of duty cycle) TA0CTL = TASSEL__ACLK + MC__UP + TACLR; // ACLK as source, up mode, clear Timer A0 TA1CCTL0 = CCIE;// + OUTMOD_7; TA1CCR0 = CYCLES_2SEC/8; //Timer A1 resets every 2 seconds TA1CTL = TASSEL__SMCLK + MC__UP + TACLR + ID_2; // SMCLK as source, up mode, clea r Timer A1, Input Clock/8 (31.25 KHz) // + TAIE; //Timer A1 interrupt enabled }
My ISRs for the Timers (I've enabled the CCR0 interrupt for both timers just to see if I can get anything to trigger, which I can't):
#pragma vector=TIMER1_A0_VECTOR __interrupt void TIMER1_A0(void){ LPM0_EXIT; TA1CTL &= ~TAIFG; //Clear the interrupt flag int temp = TA1IV; // TA1IV = 0; //clear interrupt vector } #pragma vector=TIMER0_A0_VECTOR __interrupt void TIMER0_A0(void){ LPM0_EXIT; TA0CTL &= ~TAIFG; //Clear the interrupt flag int temp = TA0IV; // TA1IV = 0; //clear interrupt vector } #pragma vector=TIMER1_A1_VECTOR __interrupt void TIMER1_A1(void){ LPM0_EXIT; TA1CTL &= ~TAIFG; //Clear the interrupt flag int temp = TA1IV; // TA1IV = 0; //clear interrupt vector } #pragma vector=TIMER0_A1_VECTOR __interrupt void TIMER0_A1(void){ LPM0_EXIT; TA0CTL &= ~TAIFG; //Clear the interrupt flag int temp = TA0IV; // TA1IV = 0; //clear interrupt vector }
As always, thank you in advance for any help you can provide.
-Chris Hack
**Attention** This is a public forum