Serial RS232 Settings

Hi there is another one,

I have a RS232 device that the only configuration possible is 9600,7,E,1

I already have a working routine for the UART but with 8,N,1

What do I need to change?

this is my Code:

void InitUART0 (void)                           //UART0 init  
{
  BCSCTL1 &= ~DIVA0;                            // ACLK = XT1 / 4 = MCLK / 4
  BCSCTL1 |= DIVA1;  
  UCTL0 = CHAR;                                 //Sart bit, 8 data bits, no parity, 1 stop
  UTCTL0 = SSEL0;                               //ACLK is UART clock
  U0BR0 = 0xd0;                                 //2000000:9600=208
  U0BR1 = 0x00;
  UMCTL0 = 0x00;                                //no modulation
  ME1 |= UTXE0 | URXE0;                         //enable UART modul
  P3SEL |= 0x30;                                // P3.4,5 = USART0 TXD/RXD
  P3DIR |= BIT4;                                //enable TXD0 as output
  P3DIR &= ~BIT5;                               //enable RXD0 as input
  IE1 |= URXIE0;                                // Enable USART0 RX interrupt  
  _EINT();                                      //enable interrupt  
}

I’m using a Olimex Easyweb II (F149) and ImageCraft Compiler

Thanks in advance

Take a look at the UCTL0 register bits in the MSP430x1xx User Guide.

gm

thanks for the tip GM, if I understand correctly, I should set UCTL= as follows:

UCTL0= PENA | PEV; //7 bit, Parity Enabled, Parity Even

That’s right, also keep in mind your BR control registers depend on your clock, a very useful tool for calculating these values for the 1xx series can be found here: http://mspgcc.sourceforge.net/baudrate.html

Mateja