- Wed Jul 23, 2014 1:04 pm
#172978
Hello all. I'm trying to get PWM working on P1.0 but it's having issues where the light is just staying on, not clearing at the end of each pulse. Now I've enable CCIE and the ISR is being execuited, but I'm unable to
have any control over the PWM. I've looked into TAIV too, but I'm having no luck whatsoever.
Could somebody please point me in the right direction please?
Thanks
have any control over the PWM. I've looked into TAIV too, but I'm having no luck whatsoever.
Could somebody please point me in the right direction please?
Thanks
Code: Select all
#include <legacymsp430.h>
void setupPorts()
{
P1DIR = 0xFF;
P1OUT = 0;
}
void setupPwm()
{
//ACLK, UP MODE, Interrupt enabled, Divide by 2
TACTL = TASSEL_1 | MC_1 | ID_1;
TACCR0 = 128;
TACCR1 = 12; //10 % duty cycle
TACCTL1 = OUTMOD_7; //Reset and set
TACCTL0 = CCIE; //Interrupt on compare
}
int main(void)
{
WDTCTL = WDTPW | WDTHOLD;
setupPorts();
setupPwm();
_BIS_SR(LPM0_bits + GIE);
return 0;
}
interrupt(TIMER0_A0_VECTOR) timera0_isr(void)
{
P1OUT ^= BIT0;
}