In the ESP32 design, pin 36 is connected to a push button and configured as input (that's all it can be anyway). and used to trigger interrupts. This is working well.
I just started to use pin 33 as an analog input, to read from a potentiometer, using AnalogRead command. This is working well, tested standalone.
When tested with the main software, it seems that AnalogRead of pin 33 is triggering an interrupt on pin 36.
When the AnalogRead of pin 33 is disabled, the problem stops. Is there a reason for that?
Are you sure? As far as I know these pins can be used as input only, without restriction on digital usage. As I mentioned, they work just fine, as long as I don't use them together.
GPIOs 34 to 39 are GPIs – input only pins. These pins don’t have internal pull-up or pull-down resistors. They can’t be used as outputs, so use these pins only as inputs:
GPIO 34
GPIO 35
GPIO 36
GPIO 39
if you want input pullup you must supply it yourself
if you digitalRead() them they are digital. if you analog Read
() them they are analog
I use external pull up resistor with GPIO 36, as input. So it is as written. GPIO36 is not really being read with DigitalRead - it is used to trigger an interrupt, which works well, as long as GPIO 33 is not AnalogRead.
Problem is solved, yet I am not sure exactly why:
I moved the AnalogRead(33) to Core0 of the ESP32, while leaving all the main code to run on Core1. This solved the problem - interrupts on GPIO36 occur normally, while AnalogRead from GPIO33 work well.
I assume that the CPU work for AnalogRead is not well synched when interrupts are set. Yet the 2 cores actually solved the problem.
I take it back - using a separated ESP32 core did NOT solve the problem. I thought so because my testing program was faulty.
Yet now the problem is really solved - the problem was with GPIO 36. Although stated it is Input only, it connected to the voltage reference of the DAC, so every AnalogRead() affected it, and caused a false interrupt. After moving the push button to another GPIO, the problem was solved.
More than that: GPIO 36 should not be used as IRQ-pin while ANY AnalogRead is used. I checked it across GPIOs for AnalogRead. However, since Espressif identified it as a bug, it may have been fixed on later version of ESP32. I may be using old ones.