Google

May 10, 2008

Serial Port interfacing with atmega

Here is the code to interface atmega32 and serial port.


.include"m32def.inc"
.org 0000
rjmp main


main: ldi r16,low(ramend)
out SPL,r16
ldi r16,high(ramend)
out SPH,r16

ldi r18,0x00
out UBRRH,r18
ldi r18,0x19 ;setting baud rate of 2400 for 1MHZ
out UBRRL,r18
ldi r19,0x18
out UCSRB,r19 ;enabling RX & TX bits
ldi r19,0x86
out UCSRC,r19 ;setting aychronous mode with 1 stop
;& 1start bit & no parity
again: rcall usart_rx
rcall usart_tx
rjmp again




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

ret


usart_tx: sbis UCSRA,UDRE
rjmp usart_tx
out UDR,r17
ret

;*************************

and set the settings in hyper terminal as

baud rate:2400
flow control:none

;********
You might be also interested in:
:: centigrade (celsius) to fahrenheit calculation for 8086 Assembly Language
:: Data transfer instructions of 8086 microprocessor


2 comments:

andiero said...

hello, my name is andiero...

i have some trouble with my project...
would you like to help me?
i need tutorial "interfacing serial port with atmega8535 +bascom avr.
source code

http://bocah-cakil.blogspot.com

To Share said...

need a help like the comment upper me