MCUCSR & WDRF

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

Hi,

 

I am a beginner with AVR and trying to experiment with watchdog timers. 

 

When a watchdog timer times out and resets, why is MCUCSR status bits all cleared in AVR Studio 4 ? As per data sheet WDRF status should be set. Is this an issue with simulation ?

 

I am yet to run the code on the hardware.

 

Any inputs will be appreciated.

 

Cheers

 

 

 

Last Edited: Fri. Sep 12, 2014 - 10:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is this an issue with simulation ?

In all likelihood, yes. 

Regards,
Steve A.

The Board helps those that help themselves.

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

In all likelihood, yes. 

I think we need to know a lot more.  In particular (and as usual) a complete small test program that demonstrates the symptoms.  AVR model.  [Clock speed and Vcc level are always useful but probably not important for this case.]  Language and toolchain used.  Tell what you expect to happen; tell what does happen.

 

Back to the comment:  Depending on the toolchain used and the phase of the moon, the flags need to be captured befor any prologue might clear any.  And WDRF in particular, as it is common practice to clear that to avoid cascading watchdog resets.

 

                 __RESET:
00001a 94f8      	CLI
00001b 27ee      	CLR  R30
00001c bbef      	OUT  EECR,R30
00001d bfe5      	OUT  MCUCR,R30
                 
                 ;DISABLE WATCHDOG
00001e e1f8      	LDI  R31,0x18
00001f 95a8      	WDR
000020 b7a4      	IN   R26,MCUSR
000021 7fa7      	CBR  R26,8
000022 bfa4      	OUT  MCUSR,R26
000023 93f0 0060 	STS  WDTCSR,R31
000025 93e0 0060 	STS  WDTCSR,R30
                 
...

 

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.

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

In the simulator, one could put a breakpoint at the reset vector and examine the flags, and then see if the startup sequence clears it.  That will determine whether it is a simulator artifact or not.

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.

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

Koshchi wrote:

Is this an issue with simulation ?

In all likelihood, yes. 

@OP, Just out of interest what do you see with a real AVR and an attached debugger?

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

First of all . Thanks to everyone who has taken their time to answer the question

 

I was able to get my task done when I downloaded my code onto the board.

 

The understanding I take from this is that you cannot simulate MCUCSR to have the relevant reset flags set , in the event of a reset, in AVR Studio 4 Simulator. Even though I was able to simulate watchdog timeouts , MCUCSR flags in the simulator never showed the reason for the resets.

 

The flags were correctly set and the code behaved and branched as I wanted , when I loaded it on to the AVR board.