; ; ********************************************** ; * Timer mit ATtiny2313, quarzgetaktet * ; * (C)2009 by http://www.avr-asm-tutorial.net * ; ********************************************** ; .nolist .include "tn2313def.inc" .list ; ; ********************************************** ; H a r d w a r e ; ********************************************** ; _______ ; 1 / |20 ; Reset o---| |---o VCC ; LCD-RS o---| |---o USCK/LCD-D7 ; LCD-E o---| AT |---o MISO/LCD-D6 ; XTAL1 o---| tiny |---o MOSI/LCD-D5 ; XTAL2 o---| 2313 |---o LCD-D4 ; KEY UP o---| |---o LCD-D3 ;KEY DWN o---| |---o LCD-D2 ;KEY STA o---| |---o LCD-D1 ; OUT o---| |---o LCD-D0 ; GND o---|________|---o LED-OUT ; ; Keys (active on key up): ; Up-key: 10 seconds longer ; Dwn-key: 10 seconds shorter ; Up-key while STA pressed: start/stop counting ; Dwn-key while STA pressed: write cycle length ; to EEPROM (value is read on start-up) ; ; ********************************************** ; C o n s t a n t s ; ********************************************** ; .equ fclock = 2457600 ; Xtal frequency ; Hardware depending constants .equ pbLcdRs = 0 ; Rs-Bit LCD .equ pbLcdE = 1 ; E-Bit LCD .equ pbOut = 5 ; Output bit .equ pbLed = 6 ; LED port bit .equ pbKeyUp = 2 ; Up-key .equ pbKeyDwn = 3 ; Down-key .equ pbKeySta = 4 ; Start/Stop-key ; ; ********************************************** ; R e g i s t e r ; ********************************************** ; ; Registers R0 ... R3 used in calculations .def rCycL = R12 ; Cycle length, LSB .def rCycH = R13 ; dto. MSB .def rPwm = R14 ; Pwm-Value .def rSreg = R15 ; save/restore SREG .def rmp = R16 ; multi purpose register .def rFlg = R17 ; Flag register .equ bSec = 0 ; second over flag .equ bOff = 1 ; end of time reached .equ bOn = 2 ; start cycle .equ bAct = 3 ; count cycle active .equ bUpd = 4 ; update cycle display .equ bSave = 5 ; save parameter for next start .def rimp = R18 ; multi purpose inside ints .def rCtrL = R24 ; LSB second counter .def rCtrH = R25 ; MSB second counter ; X = R27:R26 = duration length ; ; *********************************************** ; R e s e t / I n t e r r u p t - V e c t o r s ; *********************************************** ; .cseg .org $0000 rjmp Main rjmp Int0Isr rjmp Int1Isr rjmp Tc1CptIsr ; TC1Capt rjmp Tc1CmpAIsr ; TC1CmpA reti ; TC1Ovf reti ; TC0Ovf reti ; USART-RX reti ; USART-UDRE reti ; USART-TX reti ; AnaComp reti ; PCINT rjmp Tc1CmpBIsr ; TC1CmpB reti ; TC0CmpA reti ; TC0CmpB reti ; USI-Start reti ; USI-Ovf reti ; EEP-Rdy reti ; WDT-Ovf ; ; ********************************************** ; I n t e r r u p t S e r v i c e ; ********************************************** ; ; Up key Int0Isr: in rSreg,SREG ; save status sbis PIND,pbKeySta rjmp StartStop ldi rimp,10 ; add 10 seconds add rCycL,rimp ldi rimp,0 adc rCycH,rimp sbr rFlg,1<