WDT Reset

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

I would like to use WDT to wake-up ATTiny11 from the power-down mode. Do you have any sample programs that demonstrate this capability? I think that my problem is branching the code execution after the WDT causes a reset to occur because I can see some pins wiggle at 1.8 second intervals. I have attached a short code segment.

Reset:
ldi Temp, MCUSR
sbrs Temp,0
rjmp LED_Control ;Determine if RESET caused by POR or WDI

InitIntr: ;desired destination of power on reset
clr Temp ;Set Temp= $0
.... ;code continues to initialize processor
;but I don't want it to go here on WDT interrupt

LED_Control: ; desired destination of WDT interrupt

Any ideas?

admin's test signature
 

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

Rick there are reset adresses, I think you shoul check for the reset address on WDT reset on the part data sheet; it something like this:

.include xxxdef.inc
.org 0
rjmp reset
rjmp awake ; this is adress the contolador seeks after a sleep instruction
. ; the WDT reset should be 1 of these adresses
.
.
.
.
etc.

start: ; code

reset: reset service routine
awake: awake servise routine

admin's test signature
 

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

Data sheet Page 16, Table 5 says that the Power-On Reset and Watch Dog Reset both use the same interrupt vector.

Data sheet, page 23, Table 11 says that the MCU Status Register bit 0 is set for Power-On Reset (POR) and unchanged for all other resets, but this does not seem to work in practice. I write a zero to bit 0 during the initialization process and test bit 0 on both POR and WDT Resets. But maybe I am doing something wrong.

admin's test signature
 

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

Any RESET will start program execution from address $0, which is the first interrupt vector. If you would like to have a different startup depending on whether the RESET was caused by a Power-ON RESET or a watchdog RESET, your program should inspect the MCUSR register to se if the WDRF or the POR flags are set.

The code could look some thing like:

.org 0

rjmp RESET ;jump to RESET routine
rjmp INT0_ISR ;jump to extern interrupt interrupt service routine
; insert rjmp's to other interrupt service routines

RESET:
;here goes your "required" power on initialisation code
sbrc MCUSR,3 ;IF watchdog RESET flag set
rjmp WATCHDOG ; jump to WATCHDOG: lable
;here goes the code that should only be run if the RESET was not caused by watchdog
rjmp MAIN ;jump to the main routine
WATCHDOG:
;code to execute on watchdog RESET only
MAIN:
;main code - always executed

Hope that this throughs som light on how watchdog RESET can be handled.

Regards,
Jacob L. Lassen
Field Applications Engineer, Atmel

admin's test signature
 

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

Thank you for responding.

The specification sheet for the ATTiny10/11/12 page 22-23 indicates to me that bit 3 does provide an indicator that the WDT caused the RESET for the ATTiny12, but the ATTiny11 does not use this bit in its MCUSR. Is this correct?

This leaves me with testing the POR flag which has not been fruitful so far with almost indentical code implementations. I do clear the MCUSR in the initialization section of my code to clear the POR bit.

admin's test signature
 

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

Does anyone have sample code using the WDT to wake-up an ATTiny11 from SLEEP mode?

admin's test signature