This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR5969: MSP430FR5969 with HC-06 module

Part Number: MSP430FR5969

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;
}

  • Hi Hongmei,

    Your code halts after entering LPM0 because the MCU is asleep and the CPU is inactive, it will remain this way until your receive an interrupt from the UCA1 RXIFG. Or do you mean that the debugging session ends at this line? I did not encounter any debugging issues using CCS v7.2 and TI Compiler v17.6 and could run the example as intended.

    Regards,
    Ryan
  • Hi Ryan,

    Thanks for your replying. The code halts after LPM0, but did not receive an interrupt from UCA1 RXIFG after I sent data from phone to bluetooth module. I joint RX TX pin from bluetooth together, I could receive the letters whatever I sent, so the RX and TX on bluetooth should work.
    The debugging issue did not happen when I ran the code on CCS, but it happens with IAR 7.10.2.
    Moreover, does TXD RXD pins on header row (J13) connect to P2.0 and P2.1 on MSP430FR5969.

    Kind regards,
    Hongmei
  • Hongmei,

    P2.0/P2.1 (UCA0) connect to the eZ-FET TXD/RXD pins on J13. P2.5/UCA1TXD and P2.6/UCA1RXD are available for communication with your bluetooth device. Make sure that the HC-06 TXD is connected to the MSP430 RXD and vice versa.

    Regards,
    Ryan

  • Hi Ryan,

    I am sorry, but I still cann't make the bluetooth work.

    I have connected MSP430 P2.0/P2.1 to bluetooth module RX/TX, made sure HC-06 TXD connect to RXD on MSP430, and HC-06 RXD connect to TXD on MSP430. I load the example code "msp430fr59xx_euscia0_uart_01.c", and run the code on IAR 7.10.2; when I sent a letter from Bluetooth Terminal to HC-06, the Bluetooth Terminal receives the ascii symbol on DEC 157, which is not what I have sent. Moreover, I cannot receive signal everytime when I sent a letter, many times, I received nothing. I have also run the code on CCS 7.3.0 and TI Compiler v16.9.4.LTS, I got same results as I got from IAR.

    I also run the code that I modified to use P2.5/P2.6, and LMP0. In debugging, the code remains at LMP0, and never receive an interrupt. I used Bluetooth Terminal to send a letter to HC-06, but nothing happens.

    Thank you very much for your help.

    Hongmei

  • Hongmei,

    You cannot have three devices (Bluetooth Terminal, HC-06, and MSP430) connected on a UART bus as this will cause interference. You need to connect only the HC-06 with the MSP430 and debug inside CCS or IAR.

    Regards,
    Ryan
  • Hi Ryan,

    Bluetooth Terminal is the APP from phone, I use it to pair with HC-06 for testing the code. But at this moment, the example code doesn't work as it expected. I double checked the example, I am not sure if it is becasue LPM3 disabled SMCLK, and SMCLK has used for UART clock. So, I changed to LPM0, and enable SMCLK in system clk setting. But the problem has not been fixed by this way. I knew the example code should work, I am also sure that the bluetooth and MSP430 connection is correct, and I have tested that the bluetooth module works. But it just doesn't work as expected. 

    There is the example code I used, the Bold line is the code I added and modified. I have ran both codes (the example code without any changing, and the code below), but unfurtunly, both of them did not give the expected result. The results are same as I described on last post. 

    #include "msp430.h"

    int main(void)
    {
      WDTCTL = WDTPW | WDTHOLD;                 // Stop Watchdog

      // Configure GPIO
      P2SEL1 |= BIT0 | BIT1;                    // USCI_A0 UART operation
      P2SEL0 &= ~(BIT0 | BIT1);

      // 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_A0 for UART mode
      UCA0CTLW0 = UCSWRST;                      // Put eUSCI in reset
      UCA0CTLW0 |= UCSSEL__SMCLK;               // CLK = SMCLK
      // 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
      UCA0BR0 = 52;                             // 8000000/16/9600
      UCA0BR1 = 0x00;
      UCA0MCTLW |= UCOS16 | UCBRF_1;
      UCA0CTLW0 &= ~UCSWRST;                    // Initialize eUSCI
      UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt

      __bis_SR_register(LPM0_bits | GIE);       // Enter LPM3, interrupts enabled
      __no_operation();                         // For debugger
    }

    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=USCI_A0_VECTOR
    __interrupt void USCI_A0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      switch(__even_in_range(UCA0IV, USCI_UART_UCTXCPTIFG))
      {
        case USCI_NONE: break;
        case USCI_UART_UCRXIFG:
          while(!(UCA0IFG&UCTXIFG));
          UCA0TXBUF = UCA0RXBUF;
          __no_operation();
          break;
        case USCI_UART_UCTXIFG: break;
        case USCI_UART_UCSTTIFG: break;
        case USCI_UART_UCTXCPTIFG: break;
      }
    }

    Regards,

    Hongmei

  • msp430fr59xx_euscia0_uart_01.c works as intended and without any alterations, please make sure that J13 RXD and TXD jumpers are connected on your LaunchPad if attempting backchannel UART communication with a PC.

    Regards,
    Ryan
  • Hi Ryan,

    I think the backchannel UART communicates with PC. I upload the picture of the wire connection between bluetooth module and launchpad. On J13, expect TXD/RXD connect to Bluetooth Moduld RX/TX, the rest pins are connected with jumpers. Please kindly let me know if any connection is wrong. Thank you very much!

    Kind regards,

    Hongmei

  • The +5V pin is connected to the LaunchPad's 3.3V VCC rail. And please note that even though COM7 appears on your PC, backchannel UART is disabled with the RXD/TXD jumpers on J13 connected.

    Regards,
    Ryan

**Attention** This is a public forum