m820241125006RS232Recieve.asm


; 2024-11-25
; (C) David Vajda
; RS232 - Recieve - AVR

.include "m8def.inc"

ldi r16, HIGH (RAMEND)
out SPH, r16
ldi r16, LOW (RAMEND)
out SPL, r16

ldi r16, 0xff
out DDRB, r16

ldi r16, HIGH (25)
out UBRRH, r16
ldi r16, LOW (25)
out UBRRL, r16
ldi r16, (1 << URSEL) | (1 << UCSZ1) | (1 << UCSZ0)
out UCSRC, r16
ldi r16, (1 << RXEN)
out UCSRB, r16

loop1:
rcall rs232recieve
com r16
out PORTB, r16
rjmp loop1

rs232recieve:
sbis UCSRA, RXC
rjmp rs232recieve
in r16, UDR
ret