Compiler error: one_isr() causes a section type conflict with another_isr()

titipc
Posts: 1
Joined: Wed Dec 04, 2019 9:53 pm

Compiler error: one_isr() causes a section type conflict with another_isr()

Postby titipc » Wed Dec 04, 2019 10:26 pm

I have a project that needs to handle GPIO and time interruptions.
By compiling the code below I get:
exit status 1
void onTimer0() causes a section type conflict with void Button::isr()
  1. #define START_BUTTON 19 // gpio19    // Ligada ao botao start (iniciar ciclo)
  2. #define STOP_BUTTON  23 // gpio23    // Ligada ao botal stop all
  3.  
  4. #include <FunctionalInterrupt.h>
  5. class Button
  6. {
  7.   public:
  8.     Button(uint8_t reqPin) : PIN(reqPin) {
  9.       pinMode(PIN, INPUT_PULLUP);
  10.       attachInterrupt(PIN, std::bind(&Button::isr, this), FALLING);
  11.     };
  12.     ~Button() {
  13.       detachInterrupt(PIN);
  14.     }
  15.     void IRAM_ATTR isr() {
  16.       //numberKeyPresses += 1;
  17.       pressed = true;
  18.     }
  19.     bool checkPressed() {
  20.       bool lastPressed;
  21.       lastPressed = this->pressed;
  22.       this->pressed = false;
  23.       return lastPressed;
  24.     }
  25.   private:
  26.     const uint8_t PIN;
  27.     //volatile uint32_t numberKeyPresses;
  28.     volatile bool pressed;
  29.    
  30. };
  31. Button start_button(START_BUTTON);
  32. Button stop_button(STOP_BUTTON);
  33.  
  34. #define LedI            2      // Esp32 Pin Led
  35. byte ledI_flash=0;             // Internal led flash control
  36.  
  37. hw_timer_t * timer0 = NULL;    // timer to flash
  38.  
  39. void IRAM_ATTR onTimer0(){
  40.       if (ledI_flash) digitalWrite(LedI, digitalRead(LedI) ^ 1);   // toggle LED pin
  41. }
  42.  
  43. void setup() {
  44.   // Setup timer
  45.     timer0 = timerBegin(0, 24000, true); //timerID 0, div 80
  46.     timerAttachInterrupt(timer0, &onTimer0, true);
  47.     timerAlarmWrite(timer0, 5000, true);  
  48.     timerAlarmEnable(timer0); // enable timer  
  49.   // start flashing
  50.     ledI_flash=1;
  51. }
  52.  
  53. void loop() {
  54.   // put your main code here, to run repeatedly:
  55.      if (start_button.checkPressed()) ledI_flash=1;
  56.      if (stop_button.checkPressed()) ledI_flash=0;
  57. }
If i remove IRAM_ATTR from one or both isr statements I succeed in compiling.

I'm using Arduino 1.8.9 and appreciate any help understanding the cause and solution.
Thanks,
Tiberio

Who is online

Users browsing this forum: No registered users and 5 guests