PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : RS232 Interrupt mit einem Tiny2313



philiph
16.12.2006, 15:26
Also ich würde gerne einen Rs232 Empfangs Interrupt programmieren und ich habe das so versucht leider geht das so nicht hat vieleicht jemand ne Idee?



.include "tn2313def.inc"

.def temp = r16
.equ CLOCK = 8000000
.equ BAUD = 9600
.equ UBRRVAL = CLOCK/(BAUD*16)-1

.org 0x00
rjmp main
.org 0x0007 rjmp USART0_RXC
main:

ldi temp, LOW(RAMEND)
out SPL, temp

ldi temp, LOW(UBRRVAL)
out UBRRL, temp
ldi temp, HIGH(UBRRVAL)
out UBRRH, temp
sbi UCSRB, RXEN
sbi UCSRB,TXEN
ldi temp, (1<<USBS)|(3<<UCSZ0)
out UCSRC,temp
sei

loop:
rjmp loop

serout:
sbis UCSRA,UDRE
rjmp serout
out UDR, temp
ret

USART0_RXC:
ldi temp, '1'
rcall serout
ldi temp, '2'
rcall serout
sei
reti

p_mork
10.04.2007, 11:06
Weiss zwar nicht, ob das noch aktuell ist, aber man muss im IO-Reg UCSRB das bit RXCIE setzen. Erst dadurch wird beim Empfangen eines Bytes über den UART ein IRQ ausgelöst.

MfG Mark