This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430G2452: IAR/Pin1.1 and Pin 1.2 problems and send char to computer with UART

Part Number: MSP430G2452


Hi. I am using IAR to program MSP430G2452 on Launchpad. I have sever questions.

1, Pin1.1 P1.2 marked as UART pins on the launchpad but User's guid and datasheet said that no UART function available on Pin1.1 and P1.2. So, is UART function available on Pin1.1 P1.2?

2, Since P1.1 and P1.2 are connected with F1612. How do I send char data to computer with UART?

I know about UART and I programmed F149 to send char data to computer with UART. Just the datasheet and User's guid of G2452 so confusing me.

Code samples can help me too.

Thanks

  • Hi Bin,

    Try setting the RX and TX jumpers horizontal (=) instead of vertical (||).

    Then this code should work as an echo:

    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      if (CALBC1_1MHZ==0xFF)					// If calibration constant erased
      {											
        while(1);                               // do not load, trap CPU!!	
      }
      DCOCTL = 0;                               // Select lowest DCOx and MODx settings
      BCSCTL1 = CALBC1_1MHZ;                    // Set DCO
      DCOCTL = CALDCO_1MHZ;
      P1SEL = BIT1 + BIT2 ;                     // P1.1 = RXD, P1.2=TXD
      P1SEL2 = BIT1 + BIT2 ;                    // P1.1 = RXD, P1.2=TXD
      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
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=USCIAB0RX_VECTOR
    __interrupt void USCI0RX_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCIAB0RX_VECTOR))) USCI0RX_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      while (!(IFG2&UCA0TXIFG));                // USCI_A0 TX buffer ready?
      UCA0TXBUF = UCA0RXBUF;                    // TX -> RXed character
    }
    

  • I set my SMCLK as 2MHz.

    UCA0BR0 = 104; // 1MHz 9600
    UCA0BR1 = 0; // 1MHz 9600

    What number should be on the settings?
  • I set the SMCLK as 1MHz, So no worry on this. But bellow registers are not defined in IAR g2452.h files. Do you have an updated file?

    Error[Pe020]: identifier "IFG2" is undefined
    Error[Pe020]: identifier "UCA0TXIFG" is undefined
    Error[Pe020]: identifier "UCA0TXBUF" is undefined
    Error[Pe020]: identifier "UCA0RXBUF" is undefined
    Error[Pe020]: identifier "IFG2" is undefined
    Error[Pe020]: identifier "UCA0TXIFG" is undefined
    Error[Pe020]: identifier "UCA0TXBUF" is undefined
    Error[Pe020]: identifier "UCA0CTL1" is undefined
    Error[Pe020]: identifier "UCSSEL_2" is undefined
    Error[Pe020]: identifier "UCA0BR0" is undefined
    Error[Pe020]: identifier "UCA0BR1" is undefined
    Error[Pe020]: identifier "UCA0MCTL" is undefined
    Error[Pe020]: identifier "UCBRS0" is undefined
    Error[Pe020]: identifier "UCSWRST" is undefined
  • the 2452 variant does not have a uart inside, that's why the compiler gives those errors.

    options are:
    - find out how to code a 2452 bit-bang uart using an A_timer (check various sources)
    - if you can replace the 2452 with a 2553 processor, then you can use the uart hardware on the 2553 chip

    good luck !
  • I am buying G2553 and reading user's guid right now.

    Which part should I read?

    USART Peripheral Interface, UART Mode

    Universal Serial Communication Interface, UART Mode  

    What is the difference between topics above?

    Thanks

  • Bin,

    The USCI and USART are different comms peripherals cwith different capabailities. There is also USI and eUSCI. 

    That part has a USCI, so read the Universal Serial Communication Interface. This information can be found in the data sheet, or the functional block diagram on the part page. 

    Otto, Good Catch. Misread the partnumber... :-) 

  • Bin, Cameron - happy to help ! How can I get 'points' out of this, I wonder ?

    Bin, try first the 2553 with the USCI and the 2553 sample code. (search for it)
    The second method (bit-bang) it more complex. May I recommend the book ' MSP430 Microcontroller Basic', by John Davies. The PDF can usually found free on the web.

    Sadly, I cannot assist you further with this due to other work; good luck!

    salut, Otto
  • Otto,
    Your points automatically accumulate anytime you post or when your post is flagged as an answer. For more details. click on your rank and it shows the break down.
  • Hi, I tried on G2553. But this program is not working.
  • Have you changed your RX and TX jumpers to the HW UART configuration as shown on the silk screen? 

  • You will need to program with SW UART configuration, and then change the jumpers to HW UART (as shown above) for UART echo.
  • I changed it is working now. Thanks

**Attention** This is a public forum