Jump to content
43oh

MSP430G2553 USCI Hardware UART


Recommended Posts

Soo, I got some samples of the MSP430G2553 chips the other day, threw one in my launchpad and have been messing with the new hardware USCI UART... I had to use some jumpers to switch the TX/RX pins because of the pinout is slightly different, however I'm having some trouble sending out anything... Sample code below:

 

I'm using the sample code here provided by TI: (it's for a different chip, but modified slightly to work with the new ones.)

//******************************************************************************
//   MSP430F23x0 Demo - USCI_A0, 9600 UART Echo ISR, DCO SMCLK
//
//   Description: Echo a received character, RX ISR used. Normal mode is LPM0.
//   USCI_A0 RX interrupt triggers TX Echo.
//   Baud rate divider with 1MHz = 1MHz/9600 = ~104.2
//   ACLK = n/a, MCLK = SMCLK = CALxxx_1MHZ = 1MHz
//
//                MSP430F23x0
//             -----------------
//         /|\|              XIN|-
//          | |                 |
//          --|RST          XOUT|-
//            |                 |
//            |     P3.4/UCA0TXD|------------>
//            |                 | 9600 - 8N1
//            |     P3.5/UCA0RXD|<------------
//
//   A. Dannenberg
//   Texas Instruments Inc.
//   January 2007
//   Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.41A
//******************************************************************************
#include  "msp430g2553.h"

void main(void)
{
 WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)                                     
 {  
   while(1);                               // If calibration constants erased
                                           // do not load, trap CPU!!
 }   
 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;                     // **Initialize USCI state machine**
 IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt

 __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, interrupts enabled
}

//  Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
 while (!(IFG2&UCA0TXIFG));                // USCI_A0 TX buffer ready?
 UCA0TXBUF = UCA0RXBUF;                    // TX -> RXed character
 if(UCA0RXBUF == 0x48){ 					// toggle LED if ASCII H is sent
P1OUT ^=BIT0;
 }
}

It seems to work fine receiving data (LED toggles as expected when H is sent.), but nothing loaded into the UCA0TXBUF is being transmitted, I wonder what I've got wrong. Could it be the P1SEL? I don't really know, just wondering if anyone else has any ideas.

Link to post
Share on other sites

Been working with this some more, I tried having the TX ISR toggle an LED, looks like nothing is being sent at all, maybe I'm missing something but do i need to set anything after I fill the buffer to tell it to start transmitting? It doesn't look like I do from the datasheet.

 

#include  "msp430g2553.h"

void main(void)
{
 WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)                                     
 {  
   while(1);                               // If calibration constants erased
                                           // do not load, trap CPU!!
 }   
 BCSCTL1 = CALBC1_1MHZ;                    // Set DCO
 DCOCTL = CALDCO_1MHZ;
 P1SEL = BIT1 + BIT2;                      
 P1DIR = BIT0 + BIT6;  
 UCA0CTL1 |= UCSSEL_2;                     // SMCLK
 UCA0BR0 = 104;                            // 1MHz 9600
 UCA0BR1 = 0;                              // 1MHz 9600
 UCA0MCTL = UCBRS0;                        // Modulation UCBRSx = 1
 UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
 IE2 |= UCA0RXIE + UCA0TXIE;              // Enable USCI_A0 RX interrupt

 __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, interrupts enabled
}

//  Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCIAB0RX_VECTOR
__interrupt void USCI0RX_ISR(void)
{
 while (!(IFG2&UCA0TXIFG));                // USCI_A0 TX buffer ready?
 UCA0TXBUF = UCA0RXBUF;                    // TX -> RXed character
 if(UCA0RXBUF == 0x48){ 					// toggle LED if ASCII H is sent
P1OUT ^=BIT0;
 }
}
// toggle BIT6 (LED2) when transmitting
#pragma vector=USCIAB0TX_VECTOR
__interrupt void USCI0TX_ISR(void)
{
P1OUT ^=BIT6;
}

Link to post
Share on other sites

Throws compiler errors, I believe because that's for a different MSP430 chip series that has different register names.

 

I've been messing around with this and I really cant figure out whats wrong - from all the documentation it seems the USCI should be the same as other MSP430's that have USCI, but the transmit interrupt is just not working at all and neither is loading the transmit register. Maybe I should try over at TI's forums.

 

Thanks anyhow zeke.

Link to post
Share on other sites

Hey touch, does that mean you've got it working Sir? If so, yippee, bravo, and congrats'! And very timely, I must say, since my '2553 samples are supposed to arrive tomorrow (grin).

 

Thank you too Rob, for your always discerning eye.

 

Cheerful regards, Mike McLaren, K8LH

Link to post
Share on other sites

Gotta say Im excited by this new chips.. The Flash + RAM boost is a nice jump and the main reason Im drooling, but hardware UART is exciting also. However I do have a question.

 

The USB UART converter in the launchpad uses P1.1 as TXD and P1.2 as RXD and the signals there get transmitted back to the PC. With the hardware UART though the pins are reversed. 1.1 is USCI_A0 receive data in UART mode and 1.2 is USCI_A0 transmit data in UART mode. I remember a poll on the TI e2e site on how to handle jumpers on the next version of the board, swapping those pins.

 

Does this mean that to use the USB UART interface those of us with the <= v1.4 boards have to use bit banging?

 

I guess one possibility is that the J3 jumpers for RXD and TXD could be swapped with jumper wires. Just have to remember to swap them back when wanting to program the device.

 

Anyone who has already had a chance to play about with these devices had a chance to test this aspect of it all?

 

Thanks in advance,

 

 

Dan

Link to post
Share on other sites
In my case, I am using MAX232 plus USB-Serial bridge and no jumpers.

 

Thanks Rob. Looks like Im gunna have follow the "suck it and see" approach.. Luckily it looks as though some samples should be arriving tomorrow, not sure when I'll have the chance to play though.. Sons birthday on Sat. Wife seems to be under the impression that its the fathers job to help out with the planning and stuff..

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...