//======================================================//======================================================#include <mega16.h>#include <delay.h>
bit f=0;#define LED PORTA.7#define sw1 PINA.0#define sw2 PINA.1void 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
If you are using debugger, then you may have confirmed that no reset takes place. If not, then add a few seconds delay before while(1) to understand if a reset is actually done or not, because code enters inside blinking very fast. If you are using debugger place a breakpoint at the first line of main() to see if code hits it or not.
He didn't answer if he is using a debugger. If so, then the solution could be found in a few minutes if not seconds (and not 5 months!!!), post #6 explains how to do so.
add a few seconds delay before while(1) to understand if a reset is actually done or not, because code enters inside blinking very fast
At least did you try that out? With so small time from reset to while(), you are not sure if the MCU resets or not. Don't trust what you see, visualization depends on the wathcdog timing as well. Add a delay of 2-3 seconds before while(). Then you will be 100% sure what is going on.