Nachdem dein Zähler time2 den wert 4 erreicht hat wird der USART gestartet. Da Du aber in dieser Routine weder den Zähler time1 noch den zähler time2 zurücksetzt wird der USART durch die Comparematch Routine ständig getriggert und ständig der Wert 0 ausgegeben.
Ich hab auch noch ein paar andere Sachen umgestrickt von wegen Register sichern. Das nicht- sichern scheint ja in Mode zu kommen.
Den Fehler hab ich halt wieder mal mit dem Simulator vom AVR Studio gefunden - hat also doch seinen Sinn das Teil.
Code:.include "m8def.inc" .def temp = r16 .def counts = r17 .def kmh = r18 .def time1 = r21 .def time2 = r22 .equ CLOCK = 16000000 .equ BAUD = 9600 .equ UBRRVAL = CLOCK/(BAUD*16)-1# .org 0x000 rjmp main .org INT0addr rjmp int0_handler .org OC1Aaddr rjmp timer1_compare main: ldi temp, LOW(RAMEND) out SPL, temp ldi temp, HIGH(RAMEND) out SPH, temp ldi temp, LOW(UBRRVAL) out UBRRL, temp ldi temp, HIGH (UBRRVAL) out UBRRH, temp ldi temp, high(40000-1) out OCR1AH, temp ldi temp, low(40000-1) out OCR1AL, temp ldi temp, ( 1 << WGM12 ) | ( 1 << CS00 ) out TCCR1B, temp ldi temp, 1 << OCIE1A ; OCIE1A: Interrupt bei Timer Compare out TIMSK, temp ldi temp, (1<<URSEL)|(3<<UCSZ0) out UCSRC, temp ldi temp, 0x00 out DDRD, temp ;ldi temp, 0xFF ;out PORTD, temp ldi temp, 0b00001010 ; INT0 und INT1 konfigurieren out MCUCR, temp ldi temp, 0b11000000 ; INT0 und INT1 aktivieren out GICR, temp sbi UCSRB,TXEN sei loop: rjmp loop int0_handler: push temp in temp,sreg push temp ldi temp, 1 add counts, temp pop temp out sreg,temp pop temp reti timer1_compare: push temp in temp,sreg push temp cpi time1, 100 breq time2u brne time1w time2u: clr time1 cpi time2, 4 breq rechnekmh brne time2w time1w: inc time1 rjmp outint0 time2w: inc time2 rjmp outint0 rechnekmh: clr time2 clr kmh mov kmh, counts lsl kmh clr counts rjmp uartu uartu: sbis UCSRA, UDRE rjmp uartu out UDR, kmh outint0: pop temp out sreg,temp pop temp reti






Zitieren

Lesezeichen