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.

MSP430F5342: debugging hints needed for bluetooth module

Part Number: MSP430F5342
Other Parts Discussed in Thread: MSP-FET

Part:  MSP430F5342

Debugger:  MSP-FET

IDE:    Version: 7.4.0.00015

We are working on updating an obsolete bluetooth IC which is configured via AT commands (serial commands) from a MSP430F5342.     We are having difficultly in running debug mode and getting meaningful results to further debug.   The key functions from our project are the following:  

  •     ATxBT - configuration of data to send to the bluetooth module
  •    SendString  - calls transmit but also looks for received characters
  •    Transmit232 - sends the data

So after the microcontroller transmits $$$ in ATBT,  the bluetthe microcontroller should then receive one of three responses from the bluetooth module, which character by character are:    E-N-D,   A-O-K, or C-M-D.  When we put the cursor on the variable "received" in the IDE, it always seems to be 0 but UCA1RXBUF seems to have a value and they dont match.   Im guessing the buffer is filling up after we hit the point.  But more important is that how do we get a simple serial asciii character.   I realize there are tables but there has to be something simpler.   Any thoughts are appreciated. Is it possible that in debug mode we are getting "CMD' rather than just 'C"?

The functions being used are as follows


#include "Main.h"
#include "BluetoothAT.h"

char repeat = 0;
char flagchangebaudrate = 0;

// -----------------------------------------------------------------------------
// This function contains AT commanad with configuaration of module Bluetooth.
// AT commands sends via UART.
// -----------------------------------------------------------------------------

void ATxBT(void) {

// ------------------------------------------------------------------
// This command causes the device to ENTER COMMAND MODE, return "CMD"
repeat = 1;
while(repeat){
SendString("$$$",1);
}

}

void SendString(const char * s, int ATstate)
{
volatile char received = 0;
volatile uint32_t WaitCounter = 0;

unsigned char g;

while(*s){
g=(*s++);
Transmit232(g);
}

WaitCounter = 0x00000000;
while (!((UCA1IFG&UCRXIFG) | ((WaitCounter == 0xFFFFF)))) {
WaitCounter++;
}
received = UCA1RXBUF; // Expected "C, A or E" character
if (received == 'C' | received == 'A' | received == 'E') {
while(!(UCA1IFG&UCRXIFG));
received = UCA1RXBUF; // Expected "M, O or N" character
if (received == 'M' | received == 'O' | received == 'N') {
while(!(UCA1IFG&UCRXIFG));
received = UCA1RXBUF; // Expected "D, K or D" character
if (received == 'D' | received == 'K' | received == 'D') {
repeat = 0;
}
}
}

// READ LAST CHARACTERS RESPONSE <CR><LF>
while (!((UCA1IFG&UCRXIFG) | ((WaitCounter == 0xFFFFF))));
received = UCA1RXBUF;
while (!((UCA1IFG&UCRXIFG) | ((WaitCounter == 0xFFFFF))));
received = UCA1RXBUF;

// Change microcontroller UART Baud Rate to 115K (bluetooth default)
if (WaitCounter == 0xFFFFF){

UCA1CTL1 |= UCSWRST; // **Put state machine in reset**
UCA1CTL1 |= UCSSEL_2; // Baud Rate Source BRCLK = SMCLK

// Config 115200 baud rate with 25MHz system clock (SMLK)
// processors.wiki.ti.com/.../USCI_UART_Baud_Rate_Gen_Mode_Selection
UCA1BR0 = 217; // 115200
UCA1BR1 = 0; // 115200 According to User's Guide.
UCA1MCTL = UCBRS_0 + UCBRF_0; // Modulation UCBRSx=0, UCBRFx=0

UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UCA1IE |= UCRXIE; // Enable USCI_A1 RX interrupt

flagchangebaudrate = 1;
__delay_cycles(6000000); // Delay for UART to settle
}

}

void Transmit232(unsigned char CharToSend)
{
UCA1TXBUF = CharToSend; // Load buffer with CharToSend
while(!(UCA1IFG&UCTXIFG)); // Wait transmite complete
}

**Attention** This is a public forum