An Issue with high level interrupt
Posted: Thu Apr 16, 2020 6:32 pm
Hello everybody,
for my application I need a high level interrupt which triggers on gpio level change. Actually I want to read out an external ADC which triggers the high level interrupt at the ESP32 when a sample is ready to read out by SPI bit banging. To make deployment faster, I just wrote a minimal-example code which is normally working fine on an ESP32 board. To simulate the trigger of the ADC I just use a gpio on the ESP32 itself.
GPIO35: Interrupt pin which is tied to the High Level Interrupt xt_highint5
GPIO5: Is a "trigger" simulator and its connected to GPIO35.
If I trigger the GPIO5 slowly, the High Level Interrupt is working fine, and the SampleCounter is incremented nicely. If the trigger speed is to high the ESP32 crashes with e.g. Core 1 Panic'ed (Load Prohibited)... I also tried my application on my target board with the ADC which has a SampleRate / TriggerSpeed of only 5.9kHz, which is actually not much and it also crashes..
here you can find my minimal-code:
Assembly File:
Here is the main.c file (only relevant parts!)
For i<1000000 in the "NOP" for-loop the high level interrupt is working fine. But for example i<500000 it is crashing... The CPU is running on 240MHz.
I appreciate every help !
Best regards,
opcode_x64
for my application I need a high level interrupt which triggers on gpio level change. Actually I want to read out an external ADC which triggers the high level interrupt at the ESP32 when a sample is ready to read out by SPI bit banging. To make deployment faster, I just wrote a minimal-example code which is normally working fine on an ESP32 board. To simulate the trigger of the ADC I just use a gpio on the ESP32 itself.
GPIO35: Interrupt pin which is tied to the High Level Interrupt xt_highint5
GPIO5: Is a "trigger" simulator and its connected to GPIO35.
If I trigger the GPIO5 slowly, the High Level Interrupt is working fine, and the SampleCounter is incremented nicely. If the trigger speed is to high the ESP32 crashes with e.g. Core 1 Panic'ed (Load Prohibited)... I also tried my application on my target board with the ADC which has a SampleRate / TriggerSpeed of only 5.9kHz, which is actually not much and it also crashes..
here you can find my minimal-code:
Assembly File:
Code: Select all
#include <xtensa/coreasm.h>
#include <xtensa/corebits.h>
#include <xtensa/config/system.h>
#include "freertos/xtensa_context.h"
#include "esp_panic.h"
#include "sdkconfig.h"
#include "soc/soc.h"
#include "soc/gpio_reg.h"
#include "soc/dport_reg.h"
#define aSampleCounter a6
#define aVar a9
#define vVar a10
#define temp a11
.section .iram1,"ax"
.global xt_highint5
.type xt_highint5,@function
.align 4
xt_highint5:
// clearing the interrupt status of GPIO_NUM_35
movi aVar, GPIO_STATUS1_W1TC_REG
movi temp, (1<<3)
s32i temp, aVar, 0
memw
//incrementing the SampleCounter
movi aSampleCounter, SampleCounter
l32i vVar, aSampleCounter, 0
memw
addi.n vVar, vVar, 1
s32i vVar, aSampleCounter, 0
memw
rsr a0, EXCSAVE_5
rfi 5
Code: Select all
#define NOP __asm__ __volatile__("nop")
volatile int SampleCounter = 0;
void app_main(){
while(1){
GPIO.out_w1tc = (1<<TRIGGER_PIN);
GPIO.out_w1ts = (1<< TRIGGER_PIN);
for(i=0;i<1000000;i++){
NOP;
}
if(SampleCounter==128) break;
vTaskDelay(1);
}
printf("SampleCounter: %d\n",SampleCounter);
}
I appreciate every help !
Best regards,
opcode_x64