Other Parts Discussed in Thread: MAX3232, MSP430G2553
Hi everyone,
I'm trying to implement hardware UART into my project and so I thought I'd get started by writing some basic test code. I've been trying to get hardware UART transmit to work but have been having issues.
So far, I've just been trying to get data to at least transmit but to no avail. My setup is that I am using a MSP430 launchpad with a MSP430g2553 MCU. I connected the jumpers on the board for hardware UART. I also connected the RXD line on the launchpad (1.1) to the RXD pin on a MAX3232 board and the TXD line (1.2) of the launchpad to the TXD pin of the MAX3232 board. Of course, VCC and GND is hooked up to the MAX3232 as well. I then connect an RS232 cable from my PC to the MAX3232 board so it can connect to the microcontroller.
But when I run my code, nothing gets transmitted. This is my first doing hardware UART and I had lots of trouble finding decent sources online for doing HW UART on the MSP430.
If anybody who is more well versed in hardware UART can provide any help or corrections to my work, I would really appreciate it!
This is my current code:
#include <msp430g2553.h>
int main(void)
{
UCA0CTL1 |= UCSWRST;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
BCSCTL1 = CALBC1_1MHZ; // Set range
DCOCTL = CALDCO_1MHZ; // Set DCO step + modulation
P1SEL |= BIT1 + BIT2; //select RXD and TXD for UART
UCA0CTL0 |= UCMSB; //start MSB and UART mode
UCA0CTL1 |= UCSSEL_3;
UCA0MCTL = 0;
UCA0BR0 = 0x68; //104 9600Buad 1MHz clock
UCA0BR1 = 0x00;
//IE2 |= UCA0RXIE;
//IFG2 |= UCA0TXIFG + UCA0RXIFG;
UCA0CTL1 &= ~UCSWRST; //toggle swreset off
while (1)
{
UCA0TXBUF = 0x41;
//while ((UCA0STAT & UCBUSY)==0x01)
while (!(IFG2 & UCA0TXIFG));
_delay_cycles(100);
}
}
Thanks,
Tony