Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with using AVR UART to communicate with PC

Status
Not open for further replies.

xinz

Junior Member level 1
Joined
Jan 1, 2008
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,386
I try to use AVR's uart to communicate with my pc but failed so far.
I wrote a code to echo a byte that sent from my pc (hyperterminal,etc) back.

when I sent a byte(char) from hyperterminal, my avr always sent 0x80 back (I tried sent a-z and 0-9)
except for this char: y,i,o,j,k,l,z,x,n,m,8,9. my avr don't sent anything back.

the code:

.INCLUDE "tn2313def.inc"
RJMP Main

Main:
ldi r16, RAMEND
out SPL, r16

clr r17
ldi r16, 51

out UBRRH, r17
out UBRRL, r16

ldi r16, 0b00000110
out UCSRC, r16

ldi r16, (1 << RXEN) | (1 << TXEN)
out UCSRB, r16

readbit:
sbis UCSRA, RXC
rjmp readbit
in r17, UDR

transbit:
sbis UCSRA,UDRE
rjmp transbit

out UDR,r17
rjmp readbit


I used 8MHz crystal, I set UBRR=51 for 9600 baud rate.
I also tried different baudrate, crystal, frame format, other Atiny2313, Atmega8 but the result is failed.
I also can't say my serial port is damaged since I can update my code using AVR910 through serial port.

any solution?
 

Re: AVR UART problem

First place to start looking, would be the fuse bits. Make sure that fuses are set correctly for the type of crystal you are using.
 

AVR UART problem

Hi,
It seems fine,
Just at the end try:
Code:
readbit:
sbis UCSRA, RXC
rjmp readbit
in r17, UDR

transbit:
sbis UCSRA,UDRE
rjmp transbit

out UDR,r17

check2:
sbis UCSRA,TXC
rjmp check2

rjmp readbit

Hope it helps.
Tahmid.
 

Re: AVR UART problem

thanks.
it's a hardware problem (my dev.board).
when I test it on breadboard everything is ok
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top