Part Number: MSP430FR4133
Tool/software: Code Composer Studio
I would like to toggle an LED at interval of 1 second . Therefore I implemented the coding below . However , I could not observe any toggling most probably due to the fact that WDTIFG is never raised. I read the documentation of MSP4133 over and over again and I am aware of that WDTIE and GIE have to be set so as to raise WDTIFG. There must be something I am missing .
Another issue is that I had previously inserted WDTSSEL1 since it is 01b should have corresponded to ACLK(32kHz) .However , I realized that it was set as 10b in the registers window upon that I tried WDTSSEL0 and it yielded 01b . It did not make sense for me. If anyone could explain it , I would appreciate . Thanks in advance !.
#include <msp430.h>
#define LED BIT0
int main(void)
{
WDTCTL = WDTPW | WDTTMSEL | WDTSSEL0 | WDTCNTCL; // interval timer mode is selected, ACLK selected 32khz watch dog timer 1/32kHz * 32.768 = 1 second WDT period
P1DIR |= LED; //P1.0 is defined as output
P1OUT &= ~LED; //LED at P1.0 is turned off initially
PM5CTL0 &= ~LOCKLPM5; //previous port settings are activated.
SFRIE1 |= WDTIE; // Enable WDT interrupt
__bis_SR_register(GIE); //general interrupts enabled.
for(;;){
if((SFRIFG1 & WDTIFG) !=0){
//toggle LED once interrupt raised.
P1OUT ^= LED ; // toggles LED otherwise
WDTCTL = WDTPW | WDTTMSEL | WDTSSEL0 | WDTCNTCL; //watchdog timer starts over counting once again upto limit.
//WDTIFG is single source interrupt flag therefore automatically resets when it is serviced.
}
}
return 0;
}