Esp32c3 and interrupts > low level > c

I'm currently trying to write low level code in the C programming language for the interrupts.
ere exactly the isr is located or the jump address to it? We know from the Atmels that there is an “ISR” for every single interrupt, but how is it done with the esp32, especially with the c3?

Attached are the functions I have written so far on the subject of interrupt

interrupt.c (2,0 KB)
interrupt.h (14,0 KB)

Please post the code here, using code tags when you do, rather than attaching the files

Is this question related to programming an Arduino board and, if so, which one ?

no its not a board its only a question about a chip and interrupts^^

The ESP32 is a much more complex device than the simpler Atmel processors used on Uno, Mega, etc. There are many interdependencies in the interrupt system. If you don't want to use the standard Arduino attachInterrupt() API, then you should APIs provided by Espressif. You can get an idea by looking at the code for attachInterrupt().

Always read the documentation from Espressif
https://docs.espressif.com/projects/esp-idf/en/v5.4/esp32c3/api-reference/system/intr_alloc.html

i have read a lot but I don't find the right way for me.
in datasheet for the esp32c3 I found address for the interrupts (see picture) how I can place my c function or reference or link to this place?

Just like in Your Other Thread, you're trying to program this very complex device at the wrong level. This is not a simple 8-bit micro. You should be using the Espressif APIs. That's why they are provided. Otherwise you'll run into problems like messing up the configuration set up by Espressif's startup code. What is your motivation for stubbornly trying to go another way?

Sorry, ESP32 bare metal programming is way way beyond my skill level.

Okay :ok_hand: thanks four your Time :wink:

these days microcontroller manufacturers such as Microchip, Espressif, STM, etc provide extensive libraries to support their products
unless there is a good reason to drop into low level code (e.g. to tune some particular operation) use the libraries provided
e.g. display times between changes in HIGH/LOW on GPIO2 of ESP32C3

// ESP32C3 - display times between changes on GPIO2

#define RXPIN 2

volatile int pin = 0;     // logic pin value 1 or 0
volatile long timer = 0;  // time of change
// interrupt handler
void IRAM_ATTR handleInterrupt2() {
  pin = digitalRead(RXPIN); // read pin value
  timer = millis();         // note time
}

void setup() {
  Serial.begin(115200);
  delay(2000);
  Serial.println("\n\nESP32C3 - display times between changes on GPIO2");
  pinMode(RXPIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(RXPIN), handleInterrupt2, CHANGE);
}

void loop() {
  static int lastPin = -1;
  // if had inperrupt on pin 2 display value and time
  if (pin != lastPin) {
    lastPin = pin;
    Serial.print(timer);
    Serial.print(' ');
    Serial.println(pin);
  }
}

as GPIO2 level changes serial monitor displays

ESP32C3 - display times between changes on GPIO2
0 0
3185 1
12218 0
12218 1
12218 0
12219 1
12224 0
12225 1
12230 0
12230 1
12230 0
12231 1
12231 0
12326 1
12336 0
12337 1
12337 0

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.