; general device setup ; this is for the ATtiny 13 .NOLIST ; Disable listfile generation .include "tn13def.inc" .LIST ; light control for my shack ; simple timeouter desactivates the TRIAC if not switched off before ; ; constants @ 600 kHz clk ; .equ ROMSTART = 0x0100 .equ RAMSTART = SRAM_START .equ cr = 0x0d .equ lf = 0x0a .equ SECOND = 0x68 ; roughly a second with wozwait .equ THIRDSECOND = 0x48 ; roughly a third of a second with wozwait .equ MAXTIME = 5 ; 111 seconds multiple by this is the timeout ; hardware ports .equ Monkey = 1 ; MonkeyLives, positive logic (high = on) .equ LightOut = 2 ; Activate Light via MOC3063, low is ON .equ OptoIn = 3 ; historic designation, you could connect a pushbutton to reset the timer ; ; immediate registers .def temp = r16 ;misc usage, must be in upper regs for IMMED mode .def tempirq = r17 ;misc usage, higher byte for word access .def del = r18 ; delay counter .def counterlo = r20 ; long counter .def counterhi = r21 .def irqstor = r22 .def flags = r24 ; flags .equ lighton = 0x80 ;lights are on .equ lightonbit = 7 ; .equ sens = 0x40 ; from Optocoupler .equ sensbit = 6 ; ; ************** MAIN PROGRAM STARTS HERE ************************* .CSEG .ORG 0x0 rjmp RESET ; Reset Handler rjmp EXT_INT0 ; IRQ0 Handler rjmp PC_INT0 ; PCINT0 Handler rjmp TIM0_OVF ; Timer0 Overflow Handler rjmp EE_RDY ; EEPROM Ready Handler rjmp ANA_COMP ; Analog Comparator Handler rjmp TIM0_COMPA ; Timer0 CompareA Handler rjmp TIM0_COMPB ; Timer0 CompareB Handler rjmp WATCHDOG ; Watchdog Interrupt Handler rjmp ADC_INT ; ADC Conversion Handler TIM0_OVF: in irqstor,SREG sbi PINB, Monkey ; the monkey lives bit inc counterlo ; gearbox 1 brne tim0a inc counterhi ; gearbox 2 cpi counterhi,MAXTIME ; is counterhi lower than maxtime? brcs tim0a ; if yes, exit cbr flags,lighton ; else signal light off in tempirq,TIMSK0 cbr tempirq,(1<