Hi, I am using MSP430FR5969 launchpad communication with bluetooth HC-06 module. I used one example code and modified it, but somehow the debugging stopped at this line: __bis_SR_register(LPM0_bits | GIE); Another strange thing is I have to use "Step into" instead of "Next statement" in debugging, I have to click "Step into" a couple times until the cursor reached the first statement (Stop Watchdog). If I use "Next statement" at the first click, the code will run for a while and stop at : __bis_SR_register(LPM0_bits | GIE); I need your help because I couldn't find out the problem.
I set GPIO pin as P2.5, P2.6, USCI_A1 for UART mode, LPM0 mode. Here is my code:
#include "msp430.h"
char A;
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop Watchdog
// Configure GPIO
P2SEL1 |= BIT5 | BIT6; // USCI_A1 UART operation
P2SEL0 &= ~(BIT5 | BIT6);
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
// Startup clock system with max DCO setting ~8MHz
CSCTL0_H = CSKEY >> 8; // Unlock clock registers
CSCTL1 = DCOFSEL_3 | DCORSEL; // Set DCO to 8MHz
CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK;
CSCTL3 = DIVA__1 | DIVS__1 | DIVM__1; // Set all dividers
CSCTL4 &= ~SMCLKOFF; // Enable SMCLK
CSCTL0_H = 0; // Lock CS registers
// Configure USCI_A1 for UART mode
UCA1CTLW0 |= UCSWRST; // Put eUSCI in reset
UCA1CTLW0 |= UCSSEL__SMCLK; // CLK = SMCLK
UCA1CTLW0 |= UCBRKIE; //SET UCRXIFG
// Baud Rate calculation
// 8000000/(16*9600) = 52.083
// Fractional portion = 0.083
// User's Guide Table 21-4: UCBRSx = 0x04
// UCBRFx = int ( (52.083-52)*16) = 1
UCA1BR0 = 52; // 8000000/16/9600
UCA1BR1 = 0x00;
UCA1MCTLW |= UCOS16 | UCBRF_1;
UCA1CTLW0 &= ~UCSWRST; // Initialize eUSCI
UCA1IE |= UCRXIE; // Enable USCI_A1 RX interrupt
__bis_SR_register(LPM0_bits | GIE); // Enter LPM0, interrupts enabled
// __no_operation(); // For debugger
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A1_VECTOR
__interrupt void USCI_A1_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A1_VECTOR))) USCI_A1_ISR (void)
#else
#error Compiler not supported!
#endif
{
A = UCA1RXBUF;
}