Google

Jul 6, 2008

serial Port interfacing with atmega

This is the program for the serial communication with my atmega32.


.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:

:: Answers of Microprocessor(8085) & Electronics FAQ
:: The 8085 Microprocessor Architecture Microprocessors & Interfacing
:: How to add two binary numbers without carry

3 comments:

Digitally Your's Manmohan said...

hey can anyone give me the steps of assembling , making a makefile , hex file generation and buringing it into ATmega16. I am using WINAVR.
PLZ help me

digitrackers said...

we will get to u soon man with the steps .

To Share said...

need a code with basic language