Hi, i have MSP432 launchpad. I want to blink a led every 1second ( ON, wait 1s, OFF, wait 1s...) thanks to timerA.
So i configure my clock at 12MHz, and the timerA0 so that every 1ms the TA0CCR0 is reached. I increase a value in the interrupt routine so that every seconds the led is toggled.
What's wrong ? Well i have no tools to check my clock, and TA0CCR0 is not reached every 1ms but less. If i increase the value in my interrupt routine i can see the led blink but too fast, i have no idea what's the frequency.
I don't know what's wrong in my code, any idea ?
void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer CSKEY = CSKEY_VAL; // Unlock CS module for register access CSCTL0 = 0; // Reset tuning parameters CSCTL0 = DCORSEL_3; // Set DCO to 12MHz (nominal, center of 8-16MHz range) CSCTL1 = SELA_2 | SELS_3 | SELM_3; // Select ACLK = REFO, SMCLK = MCLK = DCO CSKEY = 0; // Lock CS module from unintended accesses __enable_interrupt(); NVIC_ISER0 = 1 << ((INT_TA0_0 - 16) & 31); P1DIR |= BIT0; // Configure P1.0 as output TA0CTL = TASSEL_2 + MC_1 + TACLR; // SMCLK, UP, clear TA0CCR0 = 12000; TA0CCTL0 = CCIE; while(1); } void TimerA0_0IsrHandler(void) { static uint32_t i = 0; i++; if(i == 1000) // 1s { P1OUT ^= BIT0; i=0; } }
Olivier.