;Citac, spolupracujici s programem pana Davida Matouska z KE2/2003 ;Mereni se spousti ridicim bytem podle teto tabulky: ; ; Doba mereni Preddelicka Ridici byt ; 0,1 s 256 00 ; 1 s 256 01 ; 10 s 256 02 ; 0,1 s 1 04 ; 1 s 1 05 ; 10 s 1 06 ; ;ATmega8 odpovi stejnym bytem. Pokud doslo k preteceni, je nastaven nejvyssi bit ;Po ridicim bytu nasleduji 2 byty se zmerenou hodnotou ;Preddelicku je treba emulovat SW, takze nelze dosahnout f vetsi nez polovina ;systemovych hodin (tj. cca 3,5MHz). To je dano hardwarem ATmega8 .include "m8def.inc" .def Zero = r0 ;Always 0 !!! .def Cnt1 = r1 .def Cnt2 = r2 .def temp0 = r16 .def temp1 = r17 .def temp2 = r18 .def temp3 = r19 .def Cnt_9_s = r20 .def Ctrl_byt = r21 .def flags =r28 ;Flags: .equ Last = 0 ;Pro urceni, pri kterem preruseni se ma ukoncit nacitani .equ Finish = 1 ;Interval uplynul .equ Presc256 = 2 .equ Overflow = 3 ;******** Crystal **************************************************** .equ fCK = 7372800 ; X-tal frequency, Hz * .equ Baud = 9600 ; Data rate, bauds * .equ Tr_Sp = 0 ; Transmission speed (U2X) * .equ UBR = -1+(5+10*fCK/(16*Baud-8*Baud*Tr_Sp))/10 ; * ; * .equ presc_1 = 1024 ; * .equ Set_0_1s = ((fCK/presc_1)/10) ;0,1s = 1/10 Hz * .equ Set_1s = ((fCK/presc_1)/1) ;1s = 1/1 Hz * .equ Set_5s = ((fCK/presc_1)/0.2) ;5s = 1/0.2 Hz * ;********************************************************************* ;########################################################################### .CSEG ;*************************************************************************** ;* ;* Interrupt Vectors ;* ;*************************************************************************** rjmp INIT ; Reset Handle reti ; External Interrupt Request 0 reti ; External Interrupt Request 1 reti ; Timer/Counter2 Compare Match reti ; Timer/Counter2 Overflow reti ; Timer/Counter1 Capture Event rjmp Interval ; Timer/Counter1 Compare Match A (Timer for measurement interval) reti ; Timer/Counter1 Compare Match B reti ; Timer/Counter1 Overflow rjmp Count ; Timer/Counter0 Overflow (External Event Count) reti ; Serial Transfer Complete reti ; USART, Rx Complete reti ; USART Data Register Empty reti ; USART, Tx Complete reti ; ADC Conversion Complete reti ; EEPROM Ready reti ; Analog Comparator reti ; 2-wire Serial Interface reti ; Store Program Memory Ready ;*************************************************************************** INIT: ldi temp1, low(RAMEND) ; SP = RAMEND ldi temp2, high(RAMEND) out SPL, temp1 out SPH, temp2 ;******************************** .if Tr_Sp ; * sbi UCSRA,U2x ; * .else ; * cbi UCSRA,U2x ; * .endif ; * ;******************************** ldi temp1, LOW(UBR) out UBRRL, temp1 .if HIGH(UBR) ldi temp1, HIGH(UBR) out UBRRH, temp1 .endif ldi temp1,(1<