Components affecting each other

lg.lindstrom
Posts: 48
Joined: Fri Sep 17, 2021 4:02 pm

Components affecting each other

Postby lg.lindstrom » Tue Nov 09, 2021 1:17 pm

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?

lg.lindstrom
Posts: 48
Joined: Fri Sep 17, 2021 4:02 pm

Re: Components affecting each other

Postby lg.lindstrom » Wed Nov 10, 2021 1:36 pm

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 ,,, ??

vonnieda
Posts: 145
Joined: Tue Nov 07, 2017 3:42 pm

Re: Components affecting each other

Postby vonnieda » Wed Nov 10, 2021 6:50 pm

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

lg.lindstrom
Posts: 48
Joined: Fri Sep 17, 2021 4:02 pm

Re: Components affecting each other

Postby lg.lindstrom » Thu Nov 11, 2021 2:51 pm

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.

Who is online

Users browsing this forum: No registered users and 64 guests