2
\$\begingroup\$

I have my MSP on Com8. Here is my code:

#include <msp430.h>
void Uart_SendChar(char c);
int main(void)
{
    WDTCTL = WDTPW + WDTHOLD;

    P4SEL |= BIT4+BIT5;                       // P3.3,4 = USCI_A0 TXD/RXD
    UCA1CTL1 |= UCSWRST;                      // **Put state machine in reset**
    UCA1CTL1 |= UCSSEL_2;                     // SMCLK
    UCA1BR0 = 9;                              // 1MHz 115200
    UCA1BR1 = 0;                              // 1MHz 115200
    UCA1MCTL |= UCBRS_1 + UCBRF_0;            // Modulation UCBRSx=1, UCBRFx=0
    UCA1CTL1 &= ~UCSWRST;

    while(1)
    {
        Uart_SendChar('k');
        __delay_cycles(3000000); //3sn Bekleme suresi
    }
}

void Uart_SendChar(char c)
{
    UCA1TXBUF=c;
    while(UCA1STAT&UCBUSY);
}

But I'm not getting any output. What might be the reason why?

\$\endgroup\$
8
  • 2
    \$\begingroup\$ You would need a scope or logic analyzer to see if there is a signal on the lines. \$\endgroup\$
    – Eugene Sh.
    Apr 23, 2021 at 20:13
  • 2
    \$\begingroup\$ Always get the TI example to run first. There should be a UART example. \$\endgroup\$
    – Mattman944
    Apr 23, 2021 at 20:25
  • \$\begingroup\$ This is based on the TI example, and there are no obvious errors. It's likely that you are using the wrong COM port, or have not configured it correctly, but you have told us nothing about that. \$\endgroup\$
    – CL.
    Apr 24, 2021 at 7:57
  • 1
    \$\begingroup\$ The most classic mistakes is connecting tx and rx wrong, or forgetting signal ground. Which is some of the numerous reasons why you absolutely need an oscilloscope in order to develop any embedded system. \$\endgroup\$
    – Lundin
    Apr 26, 2021 at 13:32
  • 1
    \$\begingroup\$ Are you trying to read from Port 3, Pin 3,4 or Port 3 Pin 4,5? Are you using a USB to Serial Cable or using the Virtual com port. Port configuration look OK as suggest by others. Below is some old code I found. I confirmed that this is working. \$\endgroup\$ Apr 27, 2021 at 2:27

1 Answer 1

2
\$\begingroup\$

Execute the following code to check if your system is working properly.

//******************************************************************************
//   MSP430F552x Demo - USCI_A0, 115200 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 1048576hz = 1048576/115200 = ~9.1 (009h|01h)
//   ACLK = REFO = ~32768Hz, MCLK = SMCLK = default DCO = 32 x ACLK = 1048576Hz
//
//                 MSP430F552x
//             -----------------
//         /|\|                 |
//          | |                 |
//          --|RST              |
//            |                 |
//            |     P3.3/UCA0TXD|------------>
//            |                 | 115200 - 8N1
//            |     P3.4/UCA0RXD|<------------
//
//******************************************************************************

#include <msp430.h>

int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

  P3SEL |= BIT3+BIT4;                       // P3.3,4 = USCI_A0 TXD/RXD
  UCA0CTL1 |= UCSWRST;                      // **Put state machine in reset**
  UCA0CTL1 |= UCSSEL_2;                     // SMCLK
  UCA0BR0 = 9;                              // 1MHz 115200 (see User's Guide)
  UCA0BR1 = 0;                              // 1MHz 115200
  UCA0MCTL |= UCBRS_1 + UCBRF_0;            // Modulation UCBRSx=1, UCBRFx=0
  UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
  UCA0IE |= UCRXIE;                         // Enable USCI_A0 RX interrupt

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

// Echo back RXed character, confirm TX buffer is ready first
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=USCI_A0_VECTOR
__interrupt void USCI_A0_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
  switch(__even_in_range(UCA0IV,4))
  {
  case 0:break;                             // Vector 0 - no interrupt
  case 2:                                   // Vector 2 - RXIFG
    while (!(UCA0IFG&UCTXIFG));             // USCI_A0 TX buffer ready?
    UCA0TXBUF = UCA0RXBUF;                  // TX -> RXed character
    break;
  case 4:break;                             // Vector 4 - TXIFG
  default: break;
  }
}

Below is output from Tera Term

enter image description here

For this demo I am using Port 3 Pin 3, 4, which in on J1 Connector. I used a USB to serial cable.

enter image description here

Below are some links that should help you get start learning how work on MSP430F5529LP. In some cases you might need to setup account on my.ti.com before you can download the material.

References:

\$\endgroup\$
4
  • 1
    \$\begingroup\$ bruh, thanks, I will try it out and revert asap \$\endgroup\$
    – RasenRhino
    Apr 28, 2021 at 19:09
  • \$\begingroup\$ much thanks, it works, I had a faulty usb. \$\endgroup\$
    – RasenRhino
    May 1, 2021 at 6:20
  • 1
    \$\begingroup\$ @RasenRhino, Thank you \$\endgroup\$ May 1, 2021 at 10:41
  • 1
    \$\begingroup\$ Glad was able to make a simple contribution to your learning journey. \$\endgroup\$ May 1, 2021 at 10:44

Not the answer you're looking for? Browse other questions tagged or ask your own question.