maxer
Member level 5
atmega32 sei
Hi!
I have done a program for atmega32 in winavr.this program uses a state machine and serial port communication.its job is to receive commands from a pc and switch relays on its output,it can also give the status of its various inputs to the pc.
Now the code functions as it should but as the pc polls the atmega32 (16Mhz Xtal) many times the micro gives a correct response but at certain undefined time the micro resets itself loosing this way the values of the registers i previously wrote to them from the PC.
Now the causes of a reset can be:
1) Power on reset (i checked the +5v and it never falls down ,it is always 5v)
so i excluded it.
2) Jtag cable which is disabled by fuse setting of JTAGEN
3) Brown out detection which is disabled by Fuse BODEN.
4) WATCHDOG.
in the code there are critical pieces of code that are run by disabling the interrupts
CLI() and after execution reenabling the global interrupts SEI().
I looked at the fuses of ATMEGA32 and it does not have a fuse for WDTEN ,watchdog enabling/disabling so i think the watchdog depends only from the values in WDTCR register.
I never used this register but to be sure i wrote a procedure to disable it :
cli( );
_WDR( );
WDTCR|=(1<<WDTOE)|(1<<WDE);
WDTCR=0X00;
sei();
Even after this the code in undetermined time resets itself.
Do you have any idea why this happens???
How can i disable permanently or temporary the watchdog in Atmega32?
thank you for your help
maXer
Hi!
I have done a program for atmega32 in winavr.this program uses a state machine and serial port communication.its job is to receive commands from a pc and switch relays on its output,it can also give the status of its various inputs to the pc.
Now the code functions as it should but as the pc polls the atmega32 (16Mhz Xtal) many times the micro gives a correct response but at certain undefined time the micro resets itself loosing this way the values of the registers i previously wrote to them from the PC.
Now the causes of a reset can be:
1) Power on reset (i checked the +5v and it never falls down ,it is always 5v)
so i excluded it.
2) Jtag cable which is disabled by fuse setting of JTAGEN
3) Brown out detection which is disabled by Fuse BODEN.
4) WATCHDOG.
in the code there are critical pieces of code that are run by disabling the interrupts
CLI() and after execution reenabling the global interrupts SEI().
I looked at the fuses of ATMEGA32 and it does not have a fuse for WDTEN ,watchdog enabling/disabling so i think the watchdog depends only from the values in WDTCR register.
I never used this register but to be sure i wrote a procedure to disable it :
cli( );
_WDR( );
WDTCR|=(1<<WDTOE)|(1<<WDE);
WDTCR=0X00;
sei();
Even after this the code in undetermined time resets itself.
Do you have any idea why this happens???
How can i disable permanently or temporary the watchdog in Atmega32?
thank you for your help
maXer