Ok, I have been attempting to get this to work, using the above advice and I am not getting behavior that indicates the ISR is being executed.
Here is my latest code
#include <stdint.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#include <util/atomic.h>
volatile byte TC0sample;
volatile unsigned int TC1sample;
volatile boolean sample_waiting = false;
void setup() {
Serial.begin(115200);
noInterrupts();
// Clear the WDRF flag
MCUSR &= ~(1 << WDRF);
// Restart the watchdog
wdt_reset();
// Prepare to configure the watchdog
_WD_CONTROL_REG = (1 << _WD_CHANGE_BIT) | (1 << WDE);
// Configure the watchdog: clear the interrupt flag; enable interrupts;
_WD_CONTROL_REG = (1 << WDIF) | (1 << WDIE);
interrupts();
Serial.println(F("TC0,TC1"));
}
void loop()
{
if (sample_waiting) {
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
{
sample_waiting = false;
Serial.print(TC0sample);
Serial.print(F(","));
Serial.print(TC1sample);
Serial.println();
}
}
}
// Watchdog Timer Interrupt Service Routine
ISR(WDT_OVERFLOW_vect)
{
TC0sample = TCNT0;
TC1sample = TCNT1;
sample_waiting = true;
}
and a sample of the output being produced...
TC0,TC1
ç,TC0,TC1
ü,TC0,TC1
ê,TC0,TC1
ç,TC0,TC1
ç,TC0,TC1
é,TC0,TC1
ô,TC0,TC1
and looking at the assembly dump, it appears the isr vector is being defined...
Disassembly of section .text:
00000000 <__vectors>:
0: 18 c0 rjmp .+48 ; 0x32 <__ctors_end>
2: 3a c0 rjmp .+116 ; 0x78 <__bad_interrupt>
4: 39 c0 rjmp .+114 ; 0x78 <__bad_interrupt>
6: 38 c0 rjmp .+112 ; 0x78 <__bad_interrupt>
8: 37 c0 rjmp .+110 ; 0x78 <__bad_interrupt>
a: 36 c0 rjmp .+108 ; 0x78 <__bad_interrupt>
c: 0a c3 rjmp .+1556 ; 0x622 <__vector_6>
e: fd c0 rjmp .+506 ; 0x20a <__vector_7>
10: 33 c0 rjmp .+102 ; 0x78 <__bad_interrupt>
12: 32 c0 rjmp .+100 ; 0x78 <__bad_interrupt>
14: 31 c0 rjmp .+98 ; 0x78 <__bad_interrupt>
16: 30 c0 rjmp .+96 ; 0x78 <__bad_interrupt>
18: 2f c0 rjmp .+94 ; 0x78 <__bad_interrupt>
1a: 2e c0 rjmp .+92 ; 0x78 <__bad_interrupt>
1c: 2d c0 rjmp .+90 ; 0x78 <__bad_interrupt>
1e: 2c c0 rjmp .+88 ; 0x78 <__bad_interrupt>
20: 2b c0 rjmp .+86 ; 0x78 <__bad_interrupt>
22: 2a c0 rjmp .+84 ; 0x78 <__bad_interrupt>
24: 64 c0 rjmp .+200 ; 0xee <__vector_18>
...
000000ee <__vector_18>:
}
}
// Watchdog Timer Interrupt Service Routine
ISR(WDT_OVERFLOW_vect)
{
ee: 1f 92 push r1
f0: 0f 92 push r0
f2: 0f b6 in r0, 0x3f ; 63
f4: 0f 92 push r0
f6: 11 24 eor r1, r1
f8: 8f 93 push r24
fa: 9f 93 push r25
TC0sample = TCNT0;
fc: 82 b7 in r24, 0x32 ; 50
fe: 80 93 72 00 sts 0x0072, r24
TC1sample = TCNT1;
102: 8c b5 in r24, 0x2c ; 44
104: 9d b5 in r25, 0x2d ; 45
106: 90 93 74 00 sts 0x0074, r25
10a: 80 93 73 00 sts 0x0073, r24
sample_waiting = true;
10e: 81 e0 ldi r24, 0x01 ; 1
110: 80 93 75 00 sts 0x0075, r24
}
114: 9f 91 pop r25
116: 8f 91 pop r24
118: 0f 90 pop r0
11a: 0f be out 0x3f, r0 ; 63
11c: 0f 90 pop r0
11e: 1f 90 pop r1
120: 18 95 reti