Hello,
I'm trying to setup UART using the USCI peripheral on the MSP430g2553 chip. I've tried two nights in a row to set things up by the manual, but it's still not working. There might be other problems present, but the code compiles. I am trying to source MCLK and ACLK from the 32kHz xtl. I know the xtl works. Trying to get BR=1200 using UCBRX 27 and UCBRSX 2.
Thank you in advance. It takes most of the fun out of it when it doesn't work as you understand it to.
Program is very simple? Just trying to send an 'H' over the UART on the launchpad.
#include <msp430g2553.h>
long i = 0;
#define LED1 BIT0
#define LED2 BIT6
void ConfigWDT(void);
void ConfigPIN(void);
void ConfigCLK(void);
void ConfigUSCI(void);
void main(void) {
ConfigWDT();
ConfigPIN();
ConfigCLK();
ConfigUSCI();
for(;;){
P1OUT ^= LED1;
__delay_cycles(15000);
if((IFG2 & UCA0TXIFG) != 0) {
UCA0TXBUF = 'H';
}
__delay_cycles(32000);
}
} //main
void ConfigWDT(void)
{
WDTCTL = WDTPW + WDTHOLD;
} //ConfigWDT
void ConfigPIN(void)
{
P2OUT = 0;
P2DIR = LED1 | LED2;
P1SEL |= (BIT1 + BIT2); //P1.1 = UCA0RXD
P1SEL2 |= (BIT1 + BIT2); //P1.2 = UCA0TXD (controlled by bit1 and bit2)
} //ConfigPIN
void ConfigCLK(void)
{
BCSCTL2 = (SELM_3);
BCSCTL3 |= (XCAP_3);
while((IFG1 & OFIFG) != 0) {
for (i=32000; i>0; i--) {
}
IFG1 ^= OFIFG;
P1OUT ^= LED2;
}
} //ConfigCLK
void ConfigUSCI(void)
{
UCA0CTL1 = 0; //resets the USCI control register
UCA0CTL0 = 0; //UART mode, No parity, LSB first, 8 data, 1 stop
UCA0CTL1 |= UCSSEL_1; //Sets it to run off of ACLK leaving reset present
UCA0BR0 = 0x1B; //lower byte of UCBR0. Setting it at dec27 I think
UCA0BR1 = 0x0; //upper byte of UCBR0. Don't need anything in that byte
UCA0MCTL = 0x4; //sets UCBRSx to 2 while keeping UCOS16=0
UCA0CTL0 &= ~BIT0; //Turns off reset
}