Tool/software: Code Composer Studio
My design needs a pin to be low for 5 minutes and then on for 5 secs and want to repeat endlessly. I thought of using the timer for this.
#include <msp430.h>
unsigned int i=1;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Configure GPIO
P1DIR |= BIT2;
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
TA0CCTL0 = CCIE; // TACCR0 interrupt enabled
TA0CCR0 = 50000;
TA0CTL = TASSEL__SMCLK | MC__CONTINOUS; // SMCLK, continuous mode
__bis_SR_register(GIE); // Enter LPM0 w/ interrupt
__no_operation(); // For debugger
}
void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) Timer0_A0_ISR (void)
{
i++;
if(i%2==0)
{
P1OUT |= BIT2;
TA0CCR0 += 50;
}
if(i%2!=0)
{
P1OUT &=0xFFFB;
TA0CCR0 +=65535;
}
}
This code works but I need a higher off time as I explained above. How can I do that?
Can I use something else other than timer to do the above operation?
Thank you in advance.
Viswanath.