[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] UART transmitting problem
From: |
Laurence Anderson |
Subject: |
[avr-gcc-list] UART transmitting problem |
Date: |
Thu, 27 Nov 2003 15:06:31 +0000 |
Hi,
Could somebody tell me if the following code should work on an AT90S8515? I'm
using 9600bps, no parity, 1 stop bit settings on the pc, but see nothing. I'm
suspicious its a hardware problem, so I'd appreciate it if somebody could
verify the code I'm using.
Cheers,
Laurence
#include <io.h>
#define F_CPU 4000000 /* 4Mhz */
#define UART_BAUD_RATE 9600 /* 9600 baud */
#define UART_BAUD_SELECT (F_CPU/(UART_BAUD_RATE*16l)-1)
char *message = "Testing, testing, 1-2-3";
int main()
{
char c, *buf = message;
// enable transmit
outp( BV(TXEN), UCR );
// set baud rate to 9600
outp( UART_BAUD_SELECT, UBRR );
while ( ( c = *(buf++) ) != '\0' ) {
loop_until_bit_is_set( USR, UDRE );
outp( c, UDR );
}
while(1); // Loop forever
}
- [avr-gcc-list] UART transmitting problem,
Laurence Anderson <=
Re: [avr-gcc-list] UART transmitting problem, Anderas Strodl, 2003/11/28