Page 1 of 1

Components affecting each other

Posted: Tue Nov 09, 2021 1:17 pm
by lg.lindstrom
I just realized that I really don't understand what I am doing :)

As many others I am writing a application for my esp32.
My environment is Vscode with Esp-idf.

My application is based on a number of classes that encapsulates the Esp-idf api.

For example.

I have a led class that have 4 methods, on, off, slowBlink, and fastBlink.
Another class is Button. It have two callbacks, shortPress and longPress.

More advanced class is the Wifi class. It have two methods, login and a callback connectionStatus.

To test my classes I create small test beds, also in C++

Code: Select all

Class TestButton : public Button {

public: TestButton() : Button("GPIO") {}

   void shortPress () override {
       ESP_LOGI(TAG, "short press detected") ;
    } 
}
Running this on my development card works quite well. Also a similar setup for the WiFi class behaves as expected.

Using the two classes together causes problem.

Code: Select all

class WiFiAndButtonTest: public WiFi, public Button {

public:
     WiFiAndButtonTest() : WiFi(), Button(GPIO) {
           Wifi::login(ssid, passed) ;
      } 

    void shortPress () override {
          ESP_LOGI(TAG, "short press detected") ;
    } 
}

In this case the a press on the button is not detected.
If I remove the wifi::login line from the code,, button press is detected.
This makes me believe that FreeRtoos somehow is involved.

I have the same problem for my Ble class.

Anyone who knows what's going on here?

Re: Components affecting each other

Posted: Wed Nov 10, 2021 1:36 pm
by lg.lindstrom
I have been digging into this more deeply.

The Button class is based on GPIO interrupt. When a interrupt occurs a timer is started and .... so on.

I used another GPIO as output where I connected a oscilloscope. Every time a GPIO interrupt occurred I toggled the output pin.

Without WiFi the output buttons toggle was caught on the oscilloscope. It happened once for every button press.

With Wifi,, the interrupt ISR seems to be called in a periodic intervall,,,, screws up my button handler.

How to debug this further ,,, ??

Re: Components affecting each other

Posted: Wed Nov 10, 2021 6:50 pm
by vonnieda
Which GPIO pins are you using for interrupts? The ESP32 has a bug (?) where GPIO36 and GPIO39 generate spurious interrupts when WiFi or BLE are on. See https://github.com/espressif/esp-idf/issues/4585

Thanks,
Jason

Re: Components affecting each other

Posted: Thu Nov 11, 2021 2:51 pm
by lg.lindstrom
Yea,, I just found out,,, and of course am I using one of those pin. Works well if I switch that pin to some else pin...

Have you seen any workaround or fix for this bug. I was not able to find anything.