So I am trying to get the UART working on my MSP430G2553 and am having some difficulty.
I am assuming that once the UCA0TXBUF is loaded with a value it is then transmitted. However the control and modulation registers must be set accordingly (which I have attempted - see that attached C file). I am trying to do 9600bps, asynchronous, no parity, 1 stop bit with a 1MHz clock (from the DCO).
All I am interested is getting the USCI_AO to spit a byte (or bytes) out right now so after initalization I intentionlly get stuck in the following while loop where I try to send the byte 0x01 out.
while(1)
{
UCA0TXBUF = 0x01; //Sending a byte to the UCAOTXBUF
}
I am not seeing anything coming out of pin 4 (USCI_A0) on my oscilloscope could somebody maybe help me get on the right track?
Thanks,
Corin
//***************************************************************************** // Blink LED Example // // Description: Toggles P1.0 by xor'ing P1.0 inside of a software loop. // This example demonstrates the ease of starting a MSP430 // project that interacts with the outside via GPIO pins. // // MSP430 // ----------------- // /|\| XIN|- // | | | // --|RST XOUT|- // | | // | P1.0|-->LED // // Texas Instruments Inc. //***************************************************************************** /* * ======== Standard MSP430 includes ======== */ #include <msp430.h> /* * ======== Grace related includes ======== */ //#include <ti/mcu/msp430/Grace.h> /* * ======== main ======== */ void CLK_INIT(void) { /* USER CODE START (section: BCSplus_graceInit_prologue) */ /* User initialization code */ /* USER CODE END (section: BCSplus_graceInit_prologue) */ /* * Basic Clock System Control 2 * * SELM_0 -- DCOCLK * DIVM_0 -- Divide by 1 * ~SELS -- DCOCLK * DIVS_0 -- Divide by 1 * ~DCOR -- DCO uses internal resistor * * Note: ~<BIT> indicates that <BIT> has value zero */ BCSCTL2 = SELM_0 + DIVM_0 + DIVS_0; if (CALBC1_1MHZ != 0xFF) { /* Follow recommended flow. First, clear all DCOx and MODx bits. Then * apply new RSELx values. Finally, apply new DCOx and MODx bit values. */ DCOCTL = 0x00; BCSCTL1 = CALBC1_1MHZ; /* Set DCO to 1MHz */ //DCOCTL = CALDCO_1MHZ; DCOCTL = 0x60; //effectively the same as line above? } /* * Basic Clock System Control 1 * * XT2OFF -- Disable XT2CLK * ~XTS -- Low Frequency * DIVA_0 -- Divide by 1 * * Note: ~XTS indicates that XTS has value zero */ BCSCTL1 |= XT2OFF + DIVA_0 + RSEL0+ RSEL2 + RSEL3; // /* * Basic Clock System Control 3 * * XT2S_0 -- 0.4 - 1 MHz * LFXT1S_2 -- If XTS = 0, XT1 = VLOCLK ; If XTS = 1, XT1 = 3 - 16-MHz crystal or resonator * XCAP_1 -- ~6 pF */ BCSCTL3 = XT2S_0 + LFXT1S_2 + XCAP_1; /* USER CODE START (section: BCSplus_graceInit_epilogue) */ /* User code */ /* USER CODE END (section: BCSplus_graceInit_epilogue) */ } void Port_INIT(void) { P1DIR = BIT0+BIT2; P1SEL = BIT2; // Primary peripheral module function is selected. // With the following line commented out (//P1SEL2 = BIT2;) //P1SEL2 = BIT2; // Secondary peripheral module function is selected. // (if P1SEL and P1SEL2 are set high) } void UART_init(void){ //int i = 0; //UCSWRST = 0x00; UCA0BR0 = 0x6D; //Baud rate settings for 1MHz (9600bps) UCA0MCTL = 0x04; //Baud rate settings for 1MHz (9600bps) //UCBRS = 0x02; //UCA0BRS0 //UCA0CTL0 = 0x00; //UCA0MCTL = 0x00; //UCA0TXIE = i; //UTXEx = 1; while(1) { UCA0TXBUF = 0x01; //Sending a byte to the UCAOTXBUF } } void initialize1(void) { /* Stop watchdog timer from timing out during initial start-up. */ WDTCTL = WDTPW | WDTHOLD; CLK_INIT(); Port_INIT(); UART_init(); } void main(void) { //Grace_init(); /* Run Grace-generated initialization */ initialize1(); while (1) { P1OUT ^= BIT0; /* Toggle LED on P1.0 */ __delay_cycles(100000); /* Wait ~100ms at DCO clock of ~1MHz */ } }