Crash in timer interrupt

Kalveo
Posts: 3
Joined: Mon Jun 26, 2017 2:27 pm

Crash in timer interrupt

Postby Kalveo » Mon Jun 26, 2017 2:33 pm

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;
        }
    }
}

ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Crash in timer interrupt

Postby ESP_Sprite » Tue Jun 27, 2017 2:37 am

What does micros() do? Also, how do you set up the interrupt?

Kalveo
Posts: 3
Joined: Mon Jun 26, 2017 2:27 pm

Re: Crash in timer interrupt

Postby Kalveo » Tue Jun 27, 2017 7:07 am

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);
}

f.h-f.s.
Posts: 215
Joined: Thu Dec 08, 2016 2:53 pm

Re: Crash in timer interrupt

Postby f.h-f.s. » Wed Jun 28, 2017 10:11 pm

if you want to know the elapsed time you can also call esp_log_early_timestamp() or esp_log_timestamp()

Who is online

Users browsing this forum: No registered users and 148 guests