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.

UART on MSP430FG4618

Hello everyone,

I get errors on every line. For e.g. Error[Pe020]: identifier "U0CTL" is undefined.

Why? Does FG4618 not support USART in UART mode? I did check up the product search.

 

Krishna.

 

_________________________________________________________________________________________________________________________

 

#include  <stdint.h>
#include <intrinsics.h>
#include <msp430xG46x.h>

#define UART_BAUD 0x0068
#define MODULATION_VAL 0x08

void main(void)
{
  // Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW | WDTHOLD;
U0CTL = CHAR | SWRST; //MM=0
U0TCTL |= SSEL0;

U0BR0 = UART_BAUD & 0xff; // Configure baud rate
U0BR1 = (UART_BAUD >> 8) & 0xff;
UMCTL0 = MODULATION_VAL; // Enable modulation
ME2 |= UTXE0 | URXE0; // Enable UART TXD/RXD

UCTL0 &= ~SWRST; // Release USART
IE2 |= URXIE0; // Enable USART RX interrupt

while(1)
{
 while(!(URCTL0 & RXWAKE));

 URXWIE = 0;

 UTXIFG = 1;

 UTCTL = TXWAKE;
 U0TXBUF = data;
 }
}

#pragma vector=USART0RX_VECTOR
__interrupt void UART0_recv_handler(void)
{
unsigned char rx_data;

// Read the UART receive buffer
rx_data = RXBUF0;
}

___________________________________________________________________________________________________________________________

  • Change it to U1xxx.

    There are code examples for this device series which you can use as a guide.

    MSP430FG461x Code Examples (Rev. D) 

  • Hi Brandon,

    I did change U0CTL to U1xxx, but I get the same error: Error[Pe020]: identifier "U1xxx" is undefined.

     

    Krishna.

  • Hello again,

    You were right, the change to U1xxx works, i.e.it works for USART1 control and status registers, but doesn't for USART0. Why so?

     

    Krishna.

  • Hi,

     

    The FG4618 is a bit of a halfway house between the 4xx series and the 5xxx series.  USCI0 is similar to (but not quite the same as) the USCIs on the 5xxx devices, USART1 is a 4xx type USART.

    USART1 code from a 4xx device will compile as expected on the 4618, but as USART0 has been replaced with USCI0 it needs new code as the registers are different.

    There are a few gotchas like this in the FG4618, despite out distributor assuring us that it was pin and code compatible with the F449 we were using previously.

    Regards,

    Phil

  • The 4618 has USART1 and USCI0. However, I'm a bit puzzled about the naming you use:

    UTCTL and U0TXBUF and UCTL0 etc. Sometimes with '0', sometimes without, sometimes teh 0 behind the U sometimes at the end.
    Then you use U0TXBUF, but RXBUF0.

    And URXWIE and UTXIFG are VALUES, not registers. You cannot assign them a value, You need to set or clear the value URXWIE in the UxRCTL register.

    No wonder that the compiler is as confused as I am.

    The best way to check what's wrong is to take a look at the msp430xG46x.h gile and the other files it includes. There you can see what is available and how it is defined.

    From the documentation, I'd expect the register names to be

    U1xxx. Not xxx, not Uxxx0, not U0xxx or Uxxx.


**Attention** This is a public forum