Forum breadcrumbs - You are here:ForumGeneral: HelpWDTCR ATtiny
You need to log in to create posts and topics.

WDTCR ATtiny

Hi

I could not update WDTCR for it has written data 00101111 from the start and not possible to update.

Is it a bug or I do something wrong?

Thanks

Hi.

Can you share your code to try to reproduce the issue?

#include <avr/interrupt.h>

#define LED_BIT _BV(PB1)

ISR(WDT_vect){
  PORTB &= ~LED_BIT;
}

int main()
{
  DDRB |= LED_BIT; // OUTPUT
  PORTB |= LED_BIT;
  cli(); 
  GIMSK |= _BV(PCIE);  
  wdt_reset();                                            
  WDTCR |= _BV(WDCE) | _BV(WDE);                //enable write
  WDTCR  = _BV(WDTIE) | _BV(WDP2) | _BV(WDP1);   //enable interrupt + 128k cycles 
  sei();                                            
                                                                                 
  while (1)
  {
  }
}  

The app very simple, I expect that in 1 sec the led should off. Bits WDP* always 1 and no interrupt.

Thanks a lot.

Uploaded files:

Hi

a question, this flag means WDTON fuse?

Quote from yurimoisa on December 15, 2025, 6:41 pm

Hi

a question, this flag means WDTON fuse?

Yes, it is basically  WDTON fuse.

ok, thanks

Have you discovered why it is not possible to change WDP* bits in WDTCR? They are always "1".

Quote from yurimoisa on December 16, 2025, 12:49 pm

ok, thanks

Have you discovered why it is not possible to change WDP* bits in WDTCR? They are always "1".

Not yet.

By the way: which ATtiny are you using?

The problem comes from interrupt bit names WDTIE and WDTIF. The default for most devices is WDIE  and WDIF.

You can fix it by editing the file: simulide/data/AVR/tiny13/tiny13_regs.xml
At line 32 add an alias for the bit names like this:

               bits="WDP0,WDP1,WDP2,WDE,WDCE,WDP3,WDTIE|WDIE,WDTIF|WDIF" />

 

 

Hi

thanks again, now WDT works well.

The only thing is that the bits WDP are always 1 in the monitor though in fact the watch dog cycle is correct exacly as it was set in the program. 

Quote from yurimoisa on December 16, 2025, 9:49 pm

The only thing is that the bits WDP are always 1 in the monitor though in fact the watch dog cycle is correct exacly as it was set in the program. 

Thank you, I will solve that issue.