Page 1 of 1

Crash in timer interrupt

Posted: Mon Jun 26, 2017 2:33 pm
by Kalveo
If I uncomment "bigBuf", all parts of the code works as intended. When i comment "bigBuf" I get "Guru Meditation Error of type IllegalInstruction occurred on core 1" and I have no idea why. Any help would be appreciated.

Code: Select all

unsigned long bigBuf[numSamplesToTake];

void IRAM_ATTR onTimer(){
    if (isSampling){
        adcBuffer[bufferIndex] = numSamples;
        //bigBuf[numSamples] = (micros());
        bufferIndex++;
        if (haveWritten && bufferIndex >= writeSize){
            toWrite = bufferIndex;
            bufferIndex = 0;
            uint16_t* t = adcBuffer;
            adcBuffer = sdBuffer;
            sdBuffer = t;
            haveWritten = false;
            shouldWrite = true;
        }
        numSamples++;
        if (numSamples >= numSamplesToTake){
            isSampling = false;
            haveWritten = false;
            shouldWrite = true;
        }
    }
}

Re: Crash in timer interrupt

Posted: Tue Jun 27, 2017 2:37 am
by ESP_Sprite
What does micros() do? Also, how do you set up the interrupt?

Re: Crash in timer interrupt

Posted: Tue Jun 27, 2017 7:07 am
by Kalveo
micros() returns the number of microseconds elapsed since startup, so it probably just reads a timer value configured by Arduino.h.

this is the setup for the timer:

Code: Select all

hw_timer_t * timer = NULL;

void setup(){
	timer = timerBegin(0, 80, true);
    	timerAttachInterrupt(timer, &onTimer, true);
	timerAlarmWrite(timer, 21, true);
	timerAlarmEnable(timer);
}

Re: Crash in timer interrupt

Posted: Wed Jun 28, 2017 10:11 pm
by f.h-f.s.
if you want to know the elapsed time you can also call esp_log_early_timestamp() or esp_log_timestamp()