touch 34 Posted May 2, 2011 Share Posted May 2, 2011 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. Quote Link to post Share on other sites
touch 34 Posted May 2, 2011 Author Share Posted May 2, 2011 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; } Quote Link to post Share on other sites
zeke 693 Posted May 3, 2011 Share Posted May 3, 2011 Try this: while ( !(UCA1IFG & UCTXIFG) ); // USCI_A0 TX buffer ready? Wait until it is. UCA1TXBUF = UCA1RXBUF; // TX -> RXed character Quote Link to post Share on other sites
touch 34 Posted May 3, 2011 Author Share Posted May 3, 2011 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. Quote Link to post Share on other sites
RobG 1,892 Posted May 3, 2011 Share Posted May 3, 2011 I think you are forgetting P1SEL2 = BIT1 + BIT2; See page 42 of datasheet Yeah, looks like this is what your are missing, see 2xx3 examples touch 1 Quote Link to post Share on other sites
touch 34 Posted May 3, 2011 Author Share Posted May 3, 2011 You are exactly right RobG... It's always the little things that get me tied up.. Thanks for that example code, I was looking all over TI's website for it. Quote Link to post Share on other sites
Mac 67 Posted May 4, 2011 Share Posted May 4, 2011 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 Quote Link to post Share on other sites
RobG 1,892 Posted May 4, 2011 Share Posted May 4, 2011 Yeah, I had that chip sitting in the socket for the past few days staring at me, but I was too busy to play with it. When I saw how simple UART code is with USCI, I couldn't resist, now we're talking! Quote Link to post Share on other sites
touch 34 Posted May 4, 2011 Author Share Posted May 4, 2011 I did get the USCI UART working, I used the example code that RobG linked. It's nice to finally be able to ditch Software UART. Quote Link to post Share on other sites
Mac 67 Posted May 4, 2011 Share Posted May 4, 2011 Thank you both for pioneering the way for the rest of us. We really appreciate it... Regards... Mike Quote Link to post Share on other sites
RobG 1,892 Posted May 4, 2011 Share Posted May 4, 2011 As much as I am excited about the hardware UART, one thing I will miss from USI is 16 bit SPI. Quote Link to post Share on other sites
DanAndDusty 62 Posted May 5, 2011 Share Posted May 5, 2011 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 Quote Link to post Share on other sites
RobG 1,892 Posted May 5, 2011 Share Posted May 5, 2011 In my case, I am using MAX232 plus USB-Serial bridge and no jumpers. DanAndDusty 1 Quote Link to post Share on other sites
DanAndDusty 62 Posted May 5, 2011 Share Posted May 5, 2011 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.. Quote Link to post Share on other sites
RobG 1,892 Posted May 5, 2011 Share Posted May 5, 2011 You could get a two row female header 2x2 and make a cross jumper. multivac and DanAndDusty 2 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.