For transmit, does checking TXC instead of UDRE limit the max
transmit speed? And what is the lag between writing to UDR and it
getting put into the transmit shift register?
Mike
--- In AVR-Chat@yahoogroups.com, JChavez@s... wrote:
>
>
>
>
>
>
> It depends on what AVR you are using however this shoul help..
>
> void RS232_init(void)
> {
> outp(0x18, UCR);
> //outp((char)UBR, UBRR);
> outp(8, UBRR); // 12=38400 8=57600 3=115200
> sbi(USR, TXC); // UART Trnsmt complete (clear TXC flag but
logical
> 1)
>
> cbi(DDRD, PD0); // RXD (UART input line)
> sbi(DDRD, PD1); // TXD (UART ouput line)
>
> }
>
> uint8_t cin(void)
> {
> loop_until_bit_is_set(USR,RXC);
> return(inp(UDR ));
> }
>
> void cout(uint8_t a)
> {
> outp(a, UDR);
> loop_until_bit_is_set(USR,TXC);
> sbi(USR, TXC); // UART Trnsmt complete (clear TXC flag but
logical
> 1)
> }
>
>
> then in main ..
>
> cout((cin());
>
> Hope this helps..
>
> JavierMessage
Re: Simple UART Code
2004-10-08 by upand_at_them
Attachments
- No local attachments were found for this message.