about software reset to attiny microcontroller

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,I am using attiny84A microcontroller.I have some topics read about software reset.Jumping to 0x00 is not recommended.The use of watchdog is recommended.I'm so confused.

 

I have a counter that increments every millisecond.I am using ISR(TIM1_COMPA_vect).When this counter reaches 1728000000 (every 20 days) I want the microcontroller to be reset. How should the correct reset configuration be done professionally for such a structure?

How should the reset code be?
Where should I write the reset code? Is it okay if I write it in ISR?with if loop example: if(counter>1728000000) reset

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Although jumping to 0x00 will restart the program, it does not "reset" all of the registers to their reset values, so that is why that is not recommended.

Since the AVR does not have a reset instruction, so that leaves you with two possible ways to "reset" your chip, one using a bit of hardware or via software using the watchdog timer.

 

1)Hardware - You know that when the chip is reset all port pins become inputs, so connecting a jumper from any unused port pin to the reset pin will let you "reset" the chip by first setting the data direction register for the port pin to be an output, then writing a "0" to that pin, will force the reset pin low, thus resetting the chip, and when reset the port will also be reset back to an input, so this clears the low on the reset pin.

 

2)Software - When you want to reset the chip (yes it would be ok to do this in an ISR()), set up the watch dog timer for a short time out, usually the default timeout value, in reset mode, then loop until the reset happens.

ie. use a while(1){}; //loop here until reset by watchdog

 

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hrn97ta wrote:
I have some topics read about software reset.Jumping to 0x00 is not recommended.The use of watchdog is recommended.I'm so confused.

Your same question in 2004:

https://www.avrfreaks.net/forum/...

Could turn on the watchdog and wait, but would like to have a better way.

And many others:

https://www.avrfreaks.net/forum/...

https://www.avrfreaks.net/forum/...

https://www.avrfreaks.net/forum/...

https://www.avrfreaks.net/forum/...

https://www.avrfreaks.net/forum/...

...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.