AVR reseting problemmo!

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

I had this piece of code in my AVR, and it ALWAYS reset the AVR.
mame_stack is a unsigned char set by a interrupt
temp_w1 unsigned int, with initial value of 0
wdt_reset is just for the efect, wd is not actualy enabled...

while((mame_stack != 1) || (temp_w1++ != 65530)) wdt_reset();

My question:
Could the reset be caused by incrementing temp_w1 over 0xFFFF? (buffer overflow)

Why did the reset happen? When I deleted this line all was OK![/i]

There are pointy haired bald people.
Time flies when you have a bad prescaler selected.

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

1. 0xFFFF is decimal 65535 (not 65530).

2. If I'm not misreading Your code completely: The condition for the while statement is written so that whenever temp_w1++ is != 65530 a call will be made to wdt_reset(). If You initialize temp_w1 to 0 (zero) the increment operator will give it the value 1, and that certainly is != 65530 and so wdt_reset() will be called.

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]