Im communicating to LabVIEW with an MSP430G2553 microcontroller through UART. The connection is a Sabrent CB-RS232 cable. The USB end is going to the computer. LabVIEW only needs to read in values. I've tried a 9600 and then a 256000 baud rate. I'm sending the same char value over and over from the MSP430. The chars that LabVIEW reads in are always different. For instance if I send a 'J' the buffer will show 'k'. It will then say '\A9' or something else if I stop LabVIew and run it again.
Everything works fine if I use the USB connection on the Launchpad. Here's the code I'm using:
#include <msp430.h>
volatile unsigned char testbuf;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
if (CALBC1_1MHZ==0xFF) // If calibration constant erased
{
while(1); // do not load, trap CPU!!
}
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
UCA0CTL1 |= UCSSEL_2 | UCPEN | ~UCPAR; // SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0x00; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
UC0IE |= UCA0TXIE; // Enable USCI_A0 RX interrupt
ADC10CTL0 = ADC10SHT_2 + ADC10ON + ADC10IE; // ADC10ON, interrupt enabled
ADC10CTL1 = INCH_4; // input A1
ADC10AE0 |= 0x10;
testbuf = 'H';
while(1)
{
ADC10CTL0 |= ENC + ADC10SC;
UCA0TXBUF = testbuf;
}
}
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
while (!(UCA0TXIFG)); // USCI_A0 TX buffer ready?
}
Does anyone have any ideas?