There is a strange behaviour related to the interpretation of DINT instruction on msp430f5438A (and probably on others msp430) in a debug session (I suppose)
With the CCS debugger I observe that when DINT is executed PC increments by 2 if the GIE bit is 0, and by 4 if is set to 1.
so the following simple code wont work as expected when stepping with the debugger, because the instruction after dint is not executed:
/*
* main.c
*/
#include <stdint.h>
#include <msp430.h>
#define LEDS_PxDIR P4DIR
#define LEDS_PxOUT P4OUT
#define LEDS_CONF_RED BIT0
#define LED_RED_ON LEDS_PxOUT &=~LEDS_CONF_RED
#define LED_RED_OFF LEDS_PxOUT |= LEDS_CONF_RED
int main(void) {
WDTCTL = WDTPW | WDTHOLD;
LEDS_PxDIR = LEDS_CONF_RED;
LED_RED_OFF;
__eint();
__no_operation();
__dint();
//__no_operation();
LED_RED_ON;
return 0;
}
A no_operation has to be inserted after dint() to fix the problem in debug mode.
When the fw runs (not in debug mode) the code executes correctly the LED_RED_ON instruction.
Does someone know the rational or it is a bug?
greetings
Attilio