As part of learning more, I have a project in mind which needs me to sample audio, so I need to trigger an ISR very frequently. After reading and searching, I have the following code:
uint32_t curcount = 0;
void ICACHE_RAM_ATTR pwm_timer_isr(){
if (curcount % 1000) {
Serial.println ("1000 hit");
Serial.printf("curcount is %d\n", curcount);
}
curcount++;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("START1");
timer1_disable();
timer1_attachInterrupt(pwm_timer_isr);
timer1_write(1);
timer1_enable(TIM_DIV265, TIM_EDGE, TIM_LOOP);
Serial.println("START2");
}
void loop() {
// put your main code here, to run repeatedly:
delay(1000);
}
Unfortunately, this only seems to reset every few seconds:
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld
START1
1000 hit
curcount is 1
1000 hit
curcount is 2
1000 hit
curcount is 3
1000 hit
curcount is 4
1000 hit
curcount is 5
1000
ets Jan 8 2013,rst cause:4, boot mode:(3,6)
wdt reset
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld
START1
1000 hit
curcount is 1
1000 hit
curcount is 2
1000 hit
curcount is 3
1000 hit
curcount is 4
1000 hit
curcount is 5
1000
Can anyone suggest what dumb mistake I'm making?