Part Number:MSP430FR6989
Hello, I am very new to micro-controllers. I have a question regarding blinking LED's in accordance with a pre-defined duty cycle using a timer. I am able to get the LED to turn on and off at equal intervals, but I'm trying to get the LED to stay on for 25% of the time, and off for the rest. My code is below.
#include "msp430.h" #include "intrinsics.h" /* Configuring Clocks Sourcing LFXTCLK to ACLK and dividing by 32. Result clock "should" be oscillating at 1 kHz. */ void configureClocks(void){ CSCTL0 = CSKEY; // Clock Control Register Password CSCTL2 = SELA__LFXTCLK; // Source LFXT to ACLK CSCTL3 = DIVA__32; // Dividing by 32 } int main(void) { configureClocks(); WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer PMMCTL0 = PMMPW; // Open PMM Module PM5CTL0 &= ~LOCKLPM5; // Clear locked IO Pins P1DIR |= BIT0; // Set P1.0 to output direction //P1OUT &= 0x00; // Initialize P1.0 TA0CCTL0 = CCIE; // Enabling interrupts from timer A TA0CCTL1 = OUTMOD_7; TA0CCR0 = 1024-1; TA0CCR1 = 256-1; // Duty cycle 25% TA0CTL = TASSEL_1 + ID_1 + MC_1; // Sourcing Timer A with ALCK, dividing by 1 _BIS_SR(LPM0_bits + GIE); } #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A (void) { P1OUT ^= BIT0; }