Hi,
I am currently attempting to use a MSP430G2553 for serial communication through UART with a Bluetooth module(attempted with HC-06 and RN-42).
I'm using an Android phone to send a letter 'a' and receive 'aaa' back. This works when i place the MSP430 into the launchpad and apply VCC and GND using a power supply (no usb connection).
The problem occurs once i remove it from the launchpad and place it onto a breadboard. Communication no longer works and i will not receive 'aaa' back. I am using a 47k pull up resistor on reset from vcc. I have also moved the jumpers horizontally to when debugging to use the hardware UART.
Below is an example of the code i have loaded onto the MSP430.
Any help is appreciated. Thanks.
#include "msp430g2553.h"
const char stringA[] = {"AAA\r\n" };
unsigned int i;
unsigned int j;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P1DIR |= BIT0;
P1SEL = BIT1+BIT2; // P3.4,5 = USCI_A0 TXD/RXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST;
IE2 |= UCA0RXIE;
P1SEL2 = BIT1 + BIT2;
__bis_SR_register(LPM0_bits + GIE);
while(1){
}
}
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void){
if (j == 0){
UCA0TXBUF=stringA[i++]; // TX next character
if (i == sizeof stringA - 1) // TX over?
UC0IE &= ~UCA0TXIE; // Disable USCI_A0 TX interrupt
}
}
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void) {
if (UCA0RXBUF=='a') // 'a' received?
{ i = 0;
j = 0;
UC0IE |= UCA0TXIE; // Enable USCI_A0 TX interrupt
}
}