Can't get the Watchdog to Interrupt on ATtiny25V

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

Hello all,

It's my first time here, after spending 2 days trying to generate an interrupt with my watchdog  :)

I am using a ATtiny25V, clock set to internal 128KHz (I plan on running it on a 2032 coin cell battery).
WDTON fuse is programmed to ensure WD is running at startup and can't be disabled.

And here is my code :

Quote:
#define F_CPU 128000UL

#include <avr/io.h>
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <avr/power.h>
#include <util/delay.h>
#include <avr/interrupt.h>

volatile uint8_t counter = 0;

void set_pins_out(){
    DDRB |= ((1 << DDB0) | (1 << DDB1) | (1 << DDB2) | (1 << DDB3) | (1 << DDB4) | (1 << DDB5));
}

void set_pins_in(){
    DDRB &= (~(1 << DDB0) | ~(1 << DDB1) | ~(1 << DDB2) | ~(1 << DDB3) | ~(1 << DDB4) | ~(1 << DDB5));
}

void init_wdt()
{
    //Disable interupts
    cli();

    //Just in case...
    WDTCR = 0x00;

    // Start timed sequence to change prescaler value : WDE = 1 & WDCE = 1
    WDTCR = (1<<WDE)|(1<<WDCE);
    
    // Set prescaler to 8 sec. WDP[3..0] = 1001, and interrupt mode.
    WDTCR = (1<<WDIE)|(1<<WDP3)|(1<<WDP0);
    
    // Enable interrupts
    sei();
}

 

ISR(WDT_vect)
{    
    // Re-enable WDT interrupt.
    WDTCR |= (1<<WDIE);
    counter++ ;
}

int main(void)
{    
    uint8_t reset_condition = MCUSR;
    MCUSR = 0x00;
    
    set_pins_out();
    
    init_wdt();
    
    while(1){
        //To Check if reset was caused by WD
        PORTB = reset_condition;
        _delay_ms(250);
        
        if(counter == 65) counter = 0;
        PORTB = counter;
        _delay_ms(1000);    
    }
}

I made sure that :

 

  1. WDTON fuse is set correctly.
  2. Configured the WD properly following the instructions of the datasheet in init_wdt().
    1. Enable changes with WDE and WDCE.
    2. Set timout and WDIE in less than 4 clock cycles.
  3. Defined a ISR with the propper vector (I checked the header to see if vector was correct).
  4. Reset WDIE in the SRI to keep it in interrupt mode.
  5. Declared the variable used in the ISR as volatile (can't verify if it works since it resets for instance...)

 

Here is the assembly code generated, to make sure that it's done in less than 4  cycles :

 

Quote:
00000044 <init_wdt>:4
}

void init_wdt()
{
    //Disable interupts
    cli();
  44:    f8 94           cli

    //Just in case...
    WDTCR = 0x00;
  46:    11 bc           out    0x21, r1    ; 33

    // Start timed sequence to change prescaler value : WDE = 1 & WDCE = 1
    WDTCR = (1<<WDE)|(1<<WDCE);
  48:    88 e1           ldi    r24, 0x18    ; 24
  4a:    81 bd           out    0x21, r24    ; 33
    
    // Set prescaler to 8 sec. WDP[3..0] = 1001, and interrupt mode.
    WDTCR = (1<<WDIE)|(1<<WDP3)|(1<<WDP0);
  4c:    81 e6           ldi    r24, 0x61    ; 97
  4e:    81 bd           out    0x21, r24    ; 33
    
    // Enable interrupts
    sei();
  50:    78 94           sei
  52:    08 95           ret

00000054 <__vector_12>:
}

 

And despite all my various attempts, the WD resets my ATtiny instead of interrupting. I can see every 8 secs it resets and shows me a MCUSR with the WDRF bit at 1 , and counter is never incremented.

So the timout is set properly at 8 secs. , but it resets instead of interrupting.

I tried for many hours, I don't understand what I am missing here ...

I tried running the ATtiny at 1 Mhz and 8 Mhz just in case there was a problem between the WD and 128KHz clock, or with my programmer at low freqs. . I tried disabling the WDTON fuse and enabling the WD in software, I tried adding 2 NOP after setting the timeout and WDIE to wait the end of the 4 cycles before doing anything else, I tried to set the WDIE after setting the timeout (after 4 clock cycles) ...  same result every time.

I don't know what to do anymore...

 

Thanks for your help !

 

P.S. : I am programming my ATtiny with a TL866II plus, and testing it on a STK500, because my USB to SERIAL adapter I use with the STK500 doesn't work anymore,

 

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

Hello again,

 

I added that in my loop out of curiosity :

 

PORTB = (WDTCR >> 4);
        _delay_ms(1000);
        
WDTCR |= (1<<WDIE);
PORTB = (WDTCR >> 4);

_delay_ms(1000);

 

So I'm reading the WDTCR, setting WDIE to 1, and reading WDTCR again (I'm flashing LEDs to debug, and the >>4 because of the only six pins of the ATtiny25)

And the 2 values are identical, the WDTCR |= (1<<WDIE); is ignored !!

WDIE is supposed to be mofiable at any time whether the watchdog is in Safety level 1 or 2 ... so I don't get it, why can't I set WDIE to 1 ?

 

Thanks for you help

 

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

Your statement to set the prescaler is setting WDE to zero.

 

Try this instead:

WDTCR = (1<<WDIE)|(1<<WDP3)|(1<<WDP0)|(1<<WDE);

 

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

Hello balisong42,

 

Thanks for the quick answer !

 

I tried, no difference, it still resets.

 

 

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

What tool chain are you using, gcc or other?

jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

Hello ki0bk,

 

I'm using avr-gcc

 

I just installed AVR Studio 7.0.2397 and didn't change anything to the config. I'm a beginner in micro-C development :)

 

I tired changing the optimization option between O1 and Os, but if I understand correctly, the only part where optimization is critical is when the WD time-out has to be set in less than 4 cycles. And from what I see in the assembly code, it seems to be the case. And it is resetting every 8 seconds. So WDP0 and 3 are set. But WDIE is ignored, whatever I do ... whether I set it in the same instruction (within 4 cycles) or not ...

Last Edited: Fri. Dec 6, 2019 - 04:15 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gcc has functions for that, see doc, these functions guarantee proper timing needed.

i know, your code should work, but does not, rtfm and use the provided functions, it’s not worth any more time trying other methods.

jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

I tried that to :( I did rtfm, many times, everything I could find, that's how I managed to arrive to a code that "should work" despite doing this for the first time.

 

I tried that :

 

ISR(WDT_vect)
{
	WDTCR |= (1<<WDIE);
	counter++;
}

void init_wdt_soft()
{
	cli();
	wdt_enable(WDTO_8S);
	WDTCR |= (1<<WDIE);
	wdt_reset();
	sei();
}

int main(void)
{	
	PORTB = 0xFF;
	set_pins_out();
	
	//init_wdt();
	init_wdt_soft();
	
	while(1){
		
		if(counter == 6) counter = 0;
		PORTB = _BV(counter);
		_delay_ms(1);
	}
}

Using wdt_enable , and WDTON fuse to 1. I can't find any more pre-made functions to do the job than that.

Still not entering my ISR (counter is not incremented, yes it's declared as volatile)

 

Thanks

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

Yakeru wrote:
 // Set prescaler to 8 sec. WDP[3..0] = 1001, and interrupt mode.
    WDTCR = (1<<WDIE)|(1<<WDP3)|(1<<WDP0);

 

im on my tablet so I don’t have access to code but iirc, you also need |(1<<WDE) on that line too, to enable wdt interrupt. You need both WDE and WDIE.

I use WDT interrupt to wake from sleep mode in most of my t25 programs, I’ll check and update tomorrow as it is past my bedtime.

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

balisong42  suggested the same thing, but it doesn't help.

 

 

 

In safety mode 1, whether I set WDE or not, it works the same (resets after 8 sec) and the datasheet says that setting WDIE clears WDE.

The table 8-2 aslo shows that the Watchdog runs if WDE or WDIE or both are set ... it just changes action (interrupt or reset). So somehow ... it makes sense.

 

In safety mode 2, datasheet says WDE is irrelevant, but I can't set WDIE whatever I do, it refuses to be set ... crazy !

 

I tried the simplest possible code to get the watchdog to run. Safety mode 1 and 2. Setting the registers by hand or using avr/wdt.h. 

 

I was able to get a 8 second reset (or any other time-out value), and waking-up from a power-down (I suppose that a reset would do that) but never was I able to send an interrupt and run the code inside the ISR.

 

I genuinely studied every "working example" (all very similar obviously) I found, read all the datasheets and online documentation from microchip, many MANY topics here and elsewhere, and it looks like many people got that thing to work with the exact same code as mine, I don't understand ...

Is it possible that my specific combination of chip+compiler+programmer is just messing stuff up ?

 

Thanks a lot for your help

 

EDIT

So here is my last attempt at coding the very simplest possible thing using the WDT interrupt and a ISR, respecting the datasheet as literally as possible, and inspired from working examples, assuming safety mode 2 :

 

#define F_CPU 128000UL
#define STK500 1

#include <avr/io.h>
#include <avr/sleep.h>
#include <avr/wdt.h>
#include <avr/power.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdlib.h>

ISR(WDT_vect)
{
	WDTCR |= (1<<WDIE);
	
	PORTB ^= (1 << PB1); //Flip led 1
}

int main(void)
{	
	//Enable Watchdog, 8 seconds, interrupt mode.
	cli();
	WDTCR = (1<<WDE)|(1<<WDCE); //Enable time-out change (WDE and WDCE to 1)
	WDTCR = (1<<WDP3)|(1<<WDP0); //Time-out to 8 sec and interrupt mode
	WDTCR |= (1<<WDIE); //Interrupt mode
	sei();
	
	DDRB = 0xFF; //Set all pins to output
	
	//Boot flash
	PORTB = 0x00;
	_delay_ms(500);
	PORTB = 0xFF;
	
	wdt_reset(); //restart WDT
	
	//Blink a led
	while(1){
		PORTB ^= (1 << PB0); //Flip led 0
		_delay_ms(500);
	}
}

When I set the time-out to 8 seconds, the datasheet tells to clear WDCE and that WDE is irrelevant, that's why I use = and not |=. (I tried both anyways)

I set WDIE after, since it is not supposed to be protected, only the WDE[3..0] require the timed sequence (I tried setting it at the time, not helping either)

In the ISR, I reset WDIE since it's cleared after the interrupt.

 

The corresponding assembly, I don't see how it could be simpler ...

 


GccApplication1.elf:     file format elf32-avr

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000098  00000000  00000000  00000054  2**1
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
  1 .data         00000000  00800060  00800060  000000ec  2**0
                  CONTENTS, ALLOC, LOAD, DATA
  2 .comment      00000030  00000000  00000000  000000ec  2**0
                  CONTENTS, READONLY
  3 .note.gnu.avr.deviceinfo 0000003c  00000000  00000000  0000011c  2**2
                  CONTENTS, READONLY
  4 .debug_aranges 00000028  00000000  00000000  00000158  2**0
                  CONTENTS, READONLY, DEBUGGING
  5 .debug_info   00000578  00000000  00000000  00000180  2**0
                  CONTENTS, READONLY, DEBUGGING
  6 .debug_abbrev 000004e8  00000000  00000000  000006f8  2**0
                  CONTENTS, READONLY, DEBUGGING
  7 .debug_line   0000026c  00000000  00000000  00000be0  2**0
                  CONTENTS, READONLY, DEBUGGING
  8 .debug_frame  00000048  00000000  00000000  00000e4c  2**2
                  CONTENTS, READONLY, DEBUGGING
  9 .debug_str    00000310  00000000  00000000  00000e94  2**0
                  CONTENTS, READONLY, DEBUGGING
 10 .debug_loc    0000008f  00000000  00000000  000011a4  2**0
                  CONTENTS, READONLY, DEBUGGING
 11 .debug_ranges 00000018  00000000  00000000  00001233  2**0
                  CONTENTS, READONLY, DEBUGGING

Disassembly of section .text:

00000000 <__vectors>:
   0:	0e c0       	rjmp	.+28     	; 0x1e <__ctors_end>
   2:	13 c0       	rjmp	.+38     	; 0x2a <__bad_interrupt>
   4:	12 c0       	rjmp	.+36     	; 0x2a <__bad_interrupt>
   6:	11 c0       	rjmp	.+34     	; 0x2a <__bad_interrupt>
   8:	10 c0       	rjmp	.+32     	; 0x2a <__bad_interrupt>
   a:	0f c0       	rjmp	.+30     	; 0x2a <__bad_interrupt>
   c:	0e c0       	rjmp	.+28     	; 0x2a <__bad_interrupt>
   e:	0d c0       	rjmp	.+26     	; 0x2a <__bad_interrupt>
  10:	0c c0       	rjmp	.+24     	; 0x2a <__bad_interrupt>
  12:	0b c0       	rjmp	.+22     	; 0x2a <__bad_interrupt>
  14:	0a c0       	rjmp	.+20     	; 0x2a <__bad_interrupt>
  16:	09 c0       	rjmp	.+18     	; 0x2a <__bad_interrupt>
  18:	09 c0       	rjmp	.+18     	; 0x2c <__vector_12>
  1a:	07 c0       	rjmp	.+14     	; 0x2a <__bad_interrupt>
  1c:	06 c0       	rjmp	.+12     	; 0x2a <__bad_interrupt>

0000001e <__ctors_end>:
  1e:	11 24       	eor	r1, r1
  20:	1f be       	out	0x3f, r1	; 63
  22:	cf ed       	ldi	r28, 0xDF	; 223
  24:	cd bf       	out	0x3d, r28	; 61
  26:	17 d0       	rcall	.+46     	; 0x56 <main>
  28:	35 c0       	rjmp	.+106    	; 0x94 <_exit>

0000002a <__bad_interrupt>:
  2a:	ea cf       	rjmp	.-44     	; 0x0 <__vectors>

0000002c <__vector_12>:
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdlib.h>

ISR(WDT_vect)
{
  2c:	1f 92       	push	r1
  2e:	0f 92       	push	r0
  30:	0f b6       	in	r0, 0x3f	; 63
  32:	0f 92       	push	r0
  34:	11 24       	eor	r1, r1
  36:	8f 93       	push	r24
  38:	9f 93       	push	r25
	WDTCR |= (1<<WDIE);
  3a:	81 b5       	in	r24, 0x21	; 33
  3c:	80 64       	ori	r24, 0x40	; 64
  3e:	81 bd       	out	0x21, r24	; 33
	
	PORTB ^= (1 << PB1); //Flip led 1
  40:	98 b3       	in	r25, 0x18	; 24
  42:	82 e0       	ldi	r24, 0x02	; 2
  44:	89 27       	eor	r24, r25
  46:	88 bb       	out	0x18, r24	; 24
}
  48:	9f 91       	pop	r25
  4a:	8f 91       	pop	r24
  4c:	0f 90       	pop	r0
  4e:	0f be       	out	0x3f, r0	; 63
  50:	0f 90       	pop	r0
  52:	1f 90       	pop	r1
  54:	18 95       	reti

00000056 <main>:

int main(void)
{	
	//Enable Watchdog, 8 seconds, interrupt mode.
	cli();
  56:	f8 94       	cli
	WDTCR = (1<<WDE)|(1<<WDCE); //Enable time-out change (WDE and WDCE to 1)
  58:	88 e1       	ldi	r24, 0x18	; 24
  5a:	81 bd       	out	0x21, r24	; 33
	WDTCR = (1<<WDP3)|(1<<WDP0); //Time-out to 8 sec and interrupt mode
  5c:	81 e2       	ldi	r24, 0x21	; 33
  5e:	81 bd       	out	0x21, r24	; 33
	WDTCR |= (1<<WDIE); //Interrupt mode
  60:	81 b5       	in	r24, 0x21	; 33
  62:	80 64       	ori	r24, 0x40	; 64
  64:	81 bd       	out	0x21, r24	; 33
	sei();
  66:	78 94       	sei
	
	DDRB = 0xFF; //Set all pins to output
  68:	8f ef       	ldi	r24, 0xFF	; 255
  6a:	87 bb       	out	0x17, r24	; 23
	
	//Boot flash
	PORTB = 0x00;
  6c:	18 ba       	out	0x18, r1	; 24
	#else
		//round up by default
		__ticks_dc = (uint32_t)(ceil(fabs(__tmp)));
	#endif

	__builtin_avr_delay_cycles(__ticks_dc);
  6e:	ef e7       	ldi	r30, 0x7F	; 127
  70:	fe e3       	ldi	r31, 0x3E	; 62
  72:	31 97       	sbiw	r30, 0x01	; 1
  74:	f1 f7       	brne	.-4      	; 0x72 <main+0x1c>
  76:	00 c0       	rjmp	.+0      	; 0x78 <main+0x22>
  78:	00 00       	nop
	_delay_ms(500);
	PORTB = 0xFF;
  7a:	88 bb       	out	0x18, r24	; 24
	
	wdt_reset(); //restart WDT
  7c:	a8 95       	wdr
	
	//Blink a led
	while(1){
		PORTB ^= (1 << PB0); //Flip led 1
  7e:	91 e0       	ldi	r25, 0x01	; 1
  80:	88 b3       	in	r24, 0x18	; 24
  82:	89 27       	eor	r24, r25
  84:	88 bb       	out	0x18, r24	; 24
  86:	ef e7       	ldi	r30, 0x7F	; 127
  88:	fe e3       	ldi	r31, 0x3E	; 62
  8a:	31 97       	sbiw	r30, 0x01	; 1
  8c:	f1 f7       	brne	.-4      	; 0x8a <main+0x34>
  8e:	00 c0       	rjmp	.+0      	; 0x90 <main+0x3a>
  90:	00 00       	nop
  92:	f6 cf       	rjmp	.-20     	; 0x80 <main+0x2a>

00000094 <_exit>:
  94:	f8 94       	cli

00000096 <__stop_program>:
  96:	ff cf       	rjmp	.-2      	; 0x96 <__stop_program>

 

After hundreds of variations on that code, this is my new starting point.

 

And the result :

 

led 0 is flipped every 500 ms

led 1 stays off

the "boot flash" plays at startup and every 8 seconds

 

Just to be sure that my understanding is correct, the interrupt should happen while inside the main loop, flip led 1, and go back in the main loop, right ? So if the WD interrupt was working as expected, we should see the "boot flash" once, and led 0 would flip every 500 ms and led 1 every 8 secs for ever. So the fact that it returns at the beginning of the code and plays "boot flash"every 8 seconds confirms that it reboots, correct ?

 

Thanks for your help

Last Edited: Fri. Dec 6, 2019 - 08:49 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well here is the code I use for WDT interrupt on a T25 project, note I do not use gcc, but instead use imagecraft, so YMMV.

 

//Watchdog initialize
// prescale: 1024K 8sec
void watchdog_init(void)
{
 WDR (); //this prevents a timeout on enabling
 WDTCR |= (1<<WDCE) | (1<<WDE); // enable WDT change
 WDTCR = (1<<WDIE) | (1<<WDE) | (1<<WDP3) | (1<<WDP2) | (1<<WDP0); //WATCHDOG ENABLED - dont forget to issue WDRs
}

 

Hope it helps.

 

Jim

edit: updated wdt code for interrupt

PS: I would not use the WDTON fuse

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Fri. Dec 6, 2019 - 03:20 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yakeru wrote:
So WDP0 and 3 are set. But WDIE is ignored, whatever I do ... whether I set it in the same instruction (within 4 cycles) or not ...

Have you tried actually using the GCC services?

 

But IIRC the last time I saw this discussed the WD interrupt case wasn't handled.

 

Indeed, different AVR model series are a bit picky in this area.  In this post is pointed out that Mega88 family is different.  Important to you is that the OP's "working" sequence was for your AVR family.

https://www.avrfreaks.net/forum/...

 

In this discussion, the setup was damn simple.  See the whole discussion...

https://www.avrfreaks.net/commen...

corrado33 wrote:

Here's a tiny program that enables interrupt only and flashes a LED attached to Port B0 (bottom right of DIP package.) (Led cannot be attached during programming.)

 

Note: This program by no means uses good practices, but it demonstrates using the watchdog timer in C with interrupts only. This program works on my Tiny85, but it should work for the whole family (Tiny25, Tiny45, Tiny85)

corrado33 wrote:
WDTCR |= 0x04; //Watchdog prescalers (how long it takes to go off) WDTCR |= 0x40; //Enable watchdog by enabling interrupt only pin

 

The poster says that this works -- a one-liner...

https://www.avrfreaks.net/forum/...

tubecut wrote:
/////////////////////////////////////////// //set_wdt() //configure WDT ,use WD interrupt, 2 sec. //time out. This will enable the WDT ////////////////////////////////////////// void set_wdt(void) { asm("wdr"); WDTCR |= (1<< WDIE) |( 1<<WDE) | (1<<WDP2) | (1<< WDP1) |(1<< WDP0); }//end set_wd()

 

The Codevision Wizard comes up with this code below.  I don't have anything here to test it right now but the CV Wizard sequences have worked for me in the past.  [Per the discussions in some of the links, the WDCE may be overkill when the WD is not running and WDTON not set.]

// Watchdog Timer initialization
// Watchdog Timer Prescaler: OSC/1024k
// Watchdog timeout action: Interrupt
#pragma optsize-
#asm("wdr")
WDTCR|=(1<<WDCE) | (1<<WDE);
WDTCR=(1<<WDIF) | (1<<WDIE) | (1<<WDP3) | (0<<WDCE) | (0<<WDE) | (0<<WDP2) | (0<<WDP1) | (1<<WDP0);
#ifdef _OPTIMIZE_SIZE_
#pragma optsize+
#endif

 

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.

Last Edited: Fri. Dec 6, 2019 - 02:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks you two :-) Really appreciated !

 

But still no success ... tried all the examples in the topics you shared. It's very disconcerting. I mean, I have exactly the same code ... than people claiming that it works !

 

I increased the frequency back to 8MHz, just in case using a 128 Khz freq. for the uC was an issue.

 

All we see from one post to another are tiny variations of the " WDTCR = (1<< WDIE) |( 1<<WDE); WDTCR = (1<<WDP2) | (1<< WDP1) |(1<< WDP0); " which is exactly what the datasheet tells to do ...

 

I can imagine that one toolchain or another may create a different assembly, but even without the WDTON flag, with no timed sequence required, it never works in my case.

 

When not using WDTON, I can see the flag WDTIE set, and it still doesn't interrupt ! And with WDTON, I can't even set WDTIE !

 

I don't get it ...

 

I don't see what else I can do, except maybe try with another micro controller, which is what I'm going to do I suppose :-(

 

Thanks again, I will let you know if I get it to work one way or another

 

 

 

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

HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

I can't believe it !!

It finally works !!

And it was an incredibly stupid mistake !! (as usual when something works for everyone except yourself)

 

I was programming the chip with the .elf file instead of the .hex !!

 

I saw from the gcc output in AVR Studio that it creates a binary .elf file, so I used that, and Xgpro V9, recognizes the format and checks "binary" (other choice being "intel hex"), programs the chip, and everything works as expected (except the interrupts of course).

 

I started to become suspicious when I noticed that the elf file is 10KB, while shopping for another uC and looking at flash capacities ... opened it in a Hex Editor, saw it was full of useless garbage, checked on google and found a topic where someone asked and was told to use the hex file.

 

UN-BE-LIE-VA-BLE

 

3 almost sleepless nights because of that ... because of a SERIAL to USB converter that isn't supported in Windows 10 anymore, forcing me to use another tool than my STK500 to program the chip, and assuming without verifying that I should use the binary file generated by AVR-GCC, which almost works, sending me off-trail in my investigations.

 

I'm genuinely choked ...

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

Yakeru wrote:
I'm genuinely choked ...

So, for future code archeologists, what is the minimal example to set up a disabled watchdog for watchdog interrupt with your model?  Is it the one-liner?

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

WDTCR = (1 << WDIE) and whichever WDPn bits you need.
Been doing it that way forever.

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

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

Hello,

 

Yeah, it looks like it ! As soon as I'm done with my current project I will try a few things to confirm the minimum code with and without the WDTON fuse.

 

Thanks again for your help !