Guys can someone just please confirm for me what the following two lines of code do?
WDTCTL = WDT_MDLY_32; // WDT Timer interval
IE1 |= WDTIE; // Enable WDT interrupt
My understanding is that the first line sets the watchdog timer (which is set up to act as an interval timer here) interval to be 32ms.
My confusion comes in the second line. I know this enables the watchdog timer interval, but my question now is when does the interrupt kick in?
Does it happen every 32ms or does it wait until the GIE bit is set?
For clarity here is the code in it's entirity:-
#include <msp430x20x3.h>
int results[100]; // holds ADC temperature result
int i = 0;
void main(void)
{
BCSCTL2 |= DIVS_3; // SMCLK/8
WDTCTL = WDT_MDLY_32; // WDT Timer interval
IE1 |= WDTIE; // Enable WDT interrupt
P1DIR |= 0x01; // P1.0 to output direction - For LED?
SD16CTL = SD16REFON +SD16SSEL_1; // 1.2V ref, SMCLK
SD16INCTL0 = SD16INCH_2; // A2 selected as I/P channel
SD16CCTL0 = SD16SNGL + SD16IE ; // Single conv, interrupt
_BIS_SR(LPM0_bits + GIE); // Enter LPM0 with interrupt
}
#pragma vector=SD16_VECTOR
__interrupt void SD16ISR(void)
{
results[ i ] = SD16MEM0; // Store value
i++;
}
// Watchdog Timer interrupt service routine
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer(void)
{
SD16CCTL0 |= SD16SC; // Start SD16 conversion
}