abdoalghareeb
Member level 5
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 //====================================================== //====================================================== #include <mega16.h> #include <delay.h> bit f=0; #define LED PORTA.7 #define sw1 PINA.0 #define sw2 PINA.1 void main(void) { PORTA=0x03; DDRA=0x80; WDTCR = 0x0e; while (1) { #asm("WDR") if (~sw1){f=1;} if (~sw2){f=0; LED=0;} if (f) { while (1) { LED ^=1; delay_ms(100); } } }; } //====================================================== //======================================================
In this code I try to test Watchdog Timer in AVR atmega 16
by pressing sw1 the led start flashing and it will continue even if I press sw2 because the progress still in while(1) loop
so I guess the Watchdog Timer can solve this problem and reset the MC
that are my Watchdog Timer settings but they didn't work
thanks..........................................................................................
Last edited by a moderator: