# MSP430G2101 WDT not triggering

I have an MSP430G2101 and I need to use the Watchdog to trigger an interrupt. The code I am trying to use is the following:

#include <msp430.h>
#include <stdint.h>

unsigned int cycle = 0;
unsigned int pwmred = 1;

void main(void)
{
WDTCTL = WDT_MDLY_0_5;              // WDT as interval timer (period 0,5 ms)
IE1 |= WDTIE;                       // Enable WDT interrupt

P1DIR |= BIT3 + BIT4 + BIT5;

_BIC_SR(GIE);
while(1)
{
}
}

#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer(void)
{
cycle++;

if(cycle >= pwmred) {
P1OUT &= ~BIT3;
}

if (cycle >= 255)
{
if(pwmred > 0)
P1OUT |= BIT3;
cycle = 0;
}
}


The interrupt is not triggering, I am checking using the debugger and it is also not acting as expection. I am using the latest version of code composer studio. Did I forget something important. I would expect the watchdog_timer method being called every 0.5 ms, but that is not working.

• any link to instruction set? – Flood Gravemind Apr 29 '17 at 23:22
• Did you tried to enable all interrupt? ( __enable_interrupt() ) – M.Ferru Apr 29 '17 at 23:56

Because you disabled global interrupts.

_BIC_SR(GIE);

Is Bit Clear Special register.

You want

_BIS_SR(GIE);

Bit Set special register.

Or use __enable_interrupt(); as mentioned.

It seems that you forgot to enable the interrupt in your code. You can enable all the interrupt with __enable_interrupt(); or enable specific interrupt with _BIS_SR(name_of_interrupt);

• Specific interrupts cannot be enabled in the SR. – CL. Apr 30 '17 at 8:43