/* SLdt 260606 Ausgangspunkt: Zitat Datenblatt: The Power Reduction Register (PRR), ... , provides a method to reduce power consumption by stopping the clock to individual peripherals. The current state of the peripheral is frozen and the I/O registers can not be read or written ... Waking up a module, which is done by clearing the bit in PRR, puts the module in the same state as before shutdown. PRR bei laufendem Timer0 mit gesetztem TOIE0 https://www.mikrocontroller.net/topic/584688#new LED an B3: blinkt mit 0.5 Hz bleibt bei Fehler stehen (nicht beim ATmega328P, da dort der Watchdog hoehere Interrupt-Prioritaet als Timer0 hat) LED an B4: zeigt Fehler: in OVF0-ISR ist TOV0 noch immer gesetzt Programm laeuft eine Weile, dann Fehler-Anzeige auf B4 (und B3) avrasm2 */ .nolist ;.include "tn13Adef.inc" .include "tn85def.inc" ;.include "m328Pdef.inc" #if __ATtiny85__ #define TIMSK0 TIMSK #define TIFR0 TIFR #define WDTIE WDIE #endif #if __ATmega328P__ #define WDTCR WDTCSR #define WDTIE WDIE #endif ;****************************************************** .macro put .if @0 < $40 out @0,@1 .else sts @0,@1 .endif .endmacro ;---------------------- .macro puti ldi tmp0,@1 put @0,tmp0 .endmacro ;---------------------- .macro get .if @1 < $40 in @0,@1 .else lds @0,@1 .endif .endmacro ;****************************************************** .list .def tmp0 = r16 .def tmp1 = r17 ;****************************************************** .cseg ; flash ;********************** .org $0000 rjmp start #if __ATmega328P__ .org WDTaddr rjmp ISR_WDT .org OVF0addr rjmp ISR_OVF0 #else .org OVF0addr rjmp ISR_OVF0 .org WDTaddr rjmp ISR_WDT #endif ;------------------------------------------------------- ISR_OVF0: push tmp0 in tmp0,TIFR0 sbrc tmp0,TOV0 sbi PORTB,4 ; 'caught in the act' ; Fehler: TOV0 ist noch immer gesetzt trotz ; 'TOV0 is cleared by hardware when executing the corresponding interrupt handling vector' pop tmp0 reti ;---------------------- ISR_WDT: sbi PINB,3 push tmp0 push tmp1 get tmp0,PRR ; PRR_PRTIM0 umschalten ldi tmp1,(1<