Gast
#233905
Hallo Leute !
Mein Programm macht folgendes: Alle 100 ms wird über UART ein 'X' an
ein Terminalprogramm gesendet. Nach 10 mal 'X' (also 1 Sek.) wird
eine '0' geschickt. Recht simpel. Tatsächlich kommt aber noch vor
jeder '0' ein seltsames Zeichen, das ich nicht bestellt habe und
nicht will. So sieht das dann aus:
XXXXXXX¬0XXXXXXXXX¬0XXXXXXXXX¬0XXXXXXXXX¬0XXXXXXXXX
Weg mit dem ¬ ! Wo kommt das her ? Wie kann ich das ausschalten /
unterdrücken ? Wer weiss einen Rat ?
Danke !
Tilman
.include "tn2313def.inc"
.def temp = r16
.def count = r24
.def count2 = r25
.equ CLOCK = 4000000
.equ BAUD = 9600
.equ UBRRVAL = CLOCK/(BAUD*16)-1
.org 0x0000
rjmp main ; Reset Handler
.org 0x0001
rjmp int0_handler
.org 0x0002
rjmp int1_handler ; IRQ1 Handler
.org 0x0006
rjmp timer0
main:
; Stackpointer initialisieren
ldi temp, LOW(RAMEND)
out SPL, temp
; Baudrate einstellen
ldi temp, LOW(UBRRVAL)
out UBRRL, temp
ldi temp, HIGH(UBRRVAL)
out UBRRH, temp
; Frame-Format: 8 Bit
ldi temp, (1<<UCSRC)|(3<<UCSZ0)
out UCSRC, temp
sbi UCSRB,TXEN ; TX aktivieren
ldi temp, 0b00000010 ;Timer 0 auf CK 8 einstellen 2µs
out TCCR0, temp ;Timer in Betrieb
ldi temp, 0b00000010 ;Timer 0 Interrupt initialisieren
out TIMSK, temp
ldi temp, 0b00000010 ;jede Änderung löst Interrupt aus
out MCUCR, temp
ldi temp, 0b11000000 ;INT0 und INT1 aktivieren
out GIMSK, temp
ldi temp, 0x00
out DDRD, temp
ldi temp, 0xFF
out DDRB, temp
sei ;Interrupts allgemein aktivieren
loop: cpi count,200 ; 102,4 ms vorbei ?
breq zehnms
cpi count2,10
breq einsek
rjmp loop
zehnms:
ldi temp,'X' ;tritt alle 10 ms ein
push temp
rcall serout
clr count
inc count2
rjmp loop
einsek:
ldi temp,'0'
push temp
rcall serout ;sollte eigentlich jede Sekunde passieren
clr count
clr count2
rjmp main
serout: sbis UCSRA,UDRE
rjmp serout
out UDR, temp
ret ; zurück zum Hauptprogramm
timer0:
;push temp
inc count
;pop temp
reti
int0_handler:
ldi temp,'G'
rcall serout
reti
int1_handler:
ldi temp,'H'
rcall serout
reti