Gast
#968058
Hallo zusammen.
Ich habe folgendes Programm zum Testen der RS232(1) beim ATmega128
geschrieben. Es soll im Zusammenspiel mit Hyperterminal die serielle
Übertragung vom und zum uC testen.
;.nolist
.include "m128def.inc"
;.list
.def temp1=r16
.def temp2=r17
.equ CLOCK = 16000000
.equ BAUD = 9600
.equ UBRRVAL = CLOCK / (BAUD*16)-1
.cseg
.org 0x0000
start:
rcall initRAM
rcall initUART
loop:
rcall receive
rcall transmit
rjmp loop
initRAM:
ldi temp1,High(RamEnd)
out sph,temp1
ldi temp1,Low(RamEnd)
out spl,temp1
ret
initUART:
ldi temp1,High(UBRRVAL)
sts UBRR1H,temp1
ldi temp1,Low(UBRRVAL)
sts UBRR1L,temp1
ldi temp1,(1<<RXEN1) | (1<<TXEN1) ;
sts UCSR1B,temp1 ; Senden und Empfangen aktiv
ldi temp1,(1<<UCSZ11) | (1<<UCSZ10) ; 8 Bit, 1 Stopbit
sts UCSR1C,temp1
ret
transmit:
lds temp1,UCSR1A
sbrs temp1,UDRE1 ; warten bis UART bereit ist
rjmp transmit
sts UDR1,temp2
ret
receive:
lds temp1,UCSR1A
sbrs temp1,RXC1
rjmp receive
lds temp2,UDR1
ret
Ich bringe es nicht zum Laufen.
In C war es kein Problem. Es hat auf Anhieb funktioniert.
Hat jemand eine Idee?
Danke im voraus