0

I'm testing some assembly code with atmega16 in Proteus 8 with AVRASM compiler and it seems that the WDR instruction isn't work correctly.

From the datasheet, WDR must just reset the watchdog counter. So if I set the watchdog timer to reset the MCU at two seconds and execute the WDR instruction, then the watchdog timer should give me another two seconds.

main:
      cbi DDRD, 5
      sbi PORTD, 5
      ldi r17, 0b00001111
      out WDTCR, r17   
loop:     
      in r16, PIND
      sbrs r16, 5
      wdr
      rjmp  loop

But in the above code, it seems that after executing WDR by providing PIND5 with 0, then the watchdog timer will never work again and as a result I don't get watchdog reset at inetravls of 2 seconds. I also check the WDTCR register and it isn't changing after executing WDR.

Wolf
  • 1
  • 1
  • Your code looks OK to me so I think there is some issue with your testing. How exactly can you tell if a watchdog reset happened? Do you blink an LED at the beginning or something? – David Grayson Apr 16 '19 at 17:36
  • I am turning a led on at it will turn off after 2 seconds. But when I press the button which executes the WDR the led behavior gets constant and it seems that it doesn't get reset anymore. And also before executing WDR the simulation log of the Protues logs the watchdog reset every two seconds but after executing WDR it wont give me this watchdog reset message. I'm starting to think that maybe it's a bug of Proteus? – Wolf Apr 16 '19 at 18:21
  • Oh, that could be. I'd try running it on some real hardware. – David Grayson Apr 16 '19 at 18:51
  • Thanks. I will test it. – Wolf Apr 17 '19 at 18:01

0 Answers0