Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

#include <msp430.

h>
void configureClocks()
{
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
if (CALBC1_1MHZ != 0xFF)
{
DCOCTL = 0; // Select lowest DCOx and MODx
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation
}
}

void delay_ms(unsigned int ms)


{
while (ms)
{
__delay_cycles(1000); //1000 for 1MHz and 16000 for 16MHz
ms--;
}
}

void main(void)
{
configureClocks();

TACCR0 = 7;
TA0CTL |= TASSEL_1+ID_1+MC_1+TACLR;
TA0CTL |= TAIE;
P1DIR |= BIT0;
P1OUT &= ~BIT0;
__enable_interrupt();
LPM0;
}

#pragma vector = TIMER0_A1_VECTOR


__interrupt void Timer_A (void)
{
if (TAIFG == 1)
//if (TA0IV == TA0IV_TAIFG)
{
P1OUT ^= BIT0;
TA0CTL &= ~(TAIFG);
}
}

You might also like