AT90S2313 GNU Compiler UART Question

Nov 14, 2003 7 Replies

Hello,


I'm trying to pass information to my terminal by using the UART on a AT90S213 board.



However, if I send more then 2 bytes, e.g a complete line, only the first two characters are shown on the screen. I checked the baudrate and the clockfrequency. I'm using the poll UART routines.



/* Initialize UART */ void InitUART( unsigned char baudrate ) { UBRR = baudrate; /* Set the baud rate */ UCR = ( (1


the

I'd rewrite it to use interrupts. See Volker Oth's gcctest program 4.

formatting link

Peter

If it does't work polling, then something very fundamental is broken (e.g. wrong register addresses). Adding interrupts to the problem isn't going to make things better.

Grant Edwards grante Yow! Where's th' DAFFY at DUCK EXHIBIT?? visi.com

the

Another thought... would it help to change this line?

into outb(UDR,data); /* Start transmission

*/

Peter

Hello,

Here is the current code.

I'm using volatile variables

===========================

#define __AVR_AT90S2313__ #include

#define UARTCONTROL 0x18 /* b00011000 0- RXCIE interrupt disabled 0- TXCIE interrupt disabled 0- UDRIE interrupt disabled 1- RXEN Receiver enabled 1- TXEN Transmitter enabled 0- 9 bit characters (for parity) disabled 0- Rest (8th bit I/O) ignore */ #define BAUDRATE 51 /* 8MHz oscillator - 9600 baud

void initUART() { outp(BAUDRATE, UBRR); outp(UARTCONTROL, UCR); }

void TransmitByte (volatile unsigned char data) { volatile unsigned char uS;

{ uS = inp(USR); } while (!(uS & 0x40)); outp(data , UDR); }

int main() { volatile unsigned char uartStatus; volatile unsigned char serialData; initUART();

TransmitByte ('b'); TransmitByte ('A'); TransmitByte ('h'); TransmitByte ('o'); TransmitByte ('i'); TransmitByte ('j'); TransmitByte ('d'); TransmitByte ('e');

}

============== The output is only 'bA' that's all !

Regards,

Bernard

Bernard Stibbe wrote: ...

It looks that you are using outdated version of GNU toolchain. Use the latest stable versions, please. At least if you want to get real support from other users.

#include

#define UARTCONTROL _BV(RXEN)|_BV(TXEN)

void initUART() { UBRR = BAUDRATE; UCR = UARTCONTROL; }

void TransmitByte (unsigned char data) { while (bit_is_clear(USR, UDRE)) ; UDR = data; }

or

void TransmitByte (unsigned char data) { while (bit_is_clear(USR, TXC)) ; USR |= _BV(TXC); UDR = data; }

Regards,

Artur Lipowski

Huh? You read the USR once, then execute an empty while loop????

Grant Edwards grante Yow! Where's th' DAFFY at DUCK EXHIBIT?? visi.com

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required