Tool/software: Code Composer Studio
Hello! I have a piece of code that successfully fades an LED in and out smoothly in about 6 seconds total. I am curious if there is a way to let a WDT_ISR do the LED brightness changes? (Perhaps in interval mode)?
#include <msp430.h> void _delay_ms(volatile unsigned int length){ volatile unsigned int delay = 0; for(delay = 0; delay < length; delay++){ _delay_cycles(1000); } } int main(void){ WDTCTL = WDTPW + WDTHOLD; // Stop WDT //**NOTE: This setup requires putting a jumper between LED1 and P1.2 on the board** P1DIR |= BIT2; //Set up Timer A 0.1(P1.2) for output P1SEL |= BIT2; //P1.2 special function SFRIE1 |= WDTIE; //Enable WDT interrupt TA0CCR0 = 350; TA0CCTL1 = OUTMOD_7; TA0CCR1 = 0; TA0CTL = TASSEL_1 + MC_1; volatile signed int i = 0; while(1){ for(i = 1; i < 309; i += 5){ TA0CCR1 = i; _delay_ms(50); } for(i = 309-1; i > 0; i -= 5){ TA0CCR1 = i; _delay_ms(50); } } }