Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By SpenZerX
#6419 Hello,

iam searching for an 2nd sample source code with an IRQ attached to an GPIO Pin.
I only have one sampe (IoT Sample).

In my code the Interrupt is firing, firing, firing a lot to often. Or is debounce required when a digital signal (0/1) is connected to GPIO? (same signal no debounce needed on arduino)
I reassigned in interrupt low state or negative edge IRQ when pin is 1 and high state or positive edge IRQ when pin is 0. Fires permanent.


SpenZerx
User avatar
By gwizz
#6433 If you want an example in lua - here is one from Peter's Gas and Electric meter reading code:

Code: Select all  -- Count GPIO at level change to 0
  -- set GPIO0 to Interrupt mode and define interrupt procedure
  gpio.mode(3,gpio.INT,gpio.PULLUP)
  gpio.trig(3, "down", IntElectric)


Pretty self-documenting, even without Peter's comments. And of course, the lua firmware is also documented here: https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en. And it's open source so even if it isn't documented well if you really want to you can poke around 'on the other side of the curtain' so to speak to work out what the acceptable parameters are etc.

As to why the interrupt is firing lots, but not in arduino, there could be lots of explanations I think. For example, perhaps the voltage is ~1.8v and so floating high for 3.3v but low enough to be always seen as 0 by the 5v arduino?

Perhaps others with deeper knowledge could talk about the difference between arduino GPIO pin and ESP? Perhaps they have different effective impedances or some other exotic effect that I should know about but don't yet?

In my experience it's common to need to debounce switches etc. but this is due to the actual physical 'bouncing' - I don't think this should apply to digital signals. I have seen on tutorial videos examples of poor termination of rf signals that results in them 'ringing' and sort of 'bouncing' off the ends of the wires but I confess I don't fully understand it!

Can you use a scope to look at the signals?

Good luck and please share your findings if you can - it will help someone else who is also stuck with this.
User avatar
By SpenZerX
#7252 Hi,
my problems are not solved.

i think my main problem is that i have 3,3 V between Pin and GND -> Pull up enabled or Output On?

But for my project pull down should be enabled & output off.

Following source sets:
3,3 V between Pin and GND
Interrupt only when Pin connected to GND

But i want:
PIN pulled DOWN
Interrupt only when Pin HIGH

#define RECEIVEGPIO 14
ETS_GPIO_INTR_DISABLE();
ETS_GPIO_INTR_ATTACH(RX_Int_Handler, RECEIVEGPIO);
REG_GPIO_ENABLE_W1TC_ADDRESS = BIT(RECEIVEGPIO); // as input
REG_GPIO_OUT_W1TC_ADDRESS = BIT(RECEIVEGPIO); // no output signal
REG_PERIPHS_IO_MUX_MTMS_U = 0b0000000001110111; // MUX_OE+MUX_SLEEP_OE+MUX_SLEEP_PULLDWN+MUX_PULLDWN+FUNC_GPIO14
REG_GPIO_PIN14_ADDRESS = 0b0000010110000010; // GPIO as Source+Driver disable+Wakeup Enabled+GPIO_PIN_INTR_ANYEDGE
REG_GPIO_STATUS_W1TC_ADDRESS = BIT(RECEIVEGPIO);
ETS_GPIO_INTR_ENABLE();

Now i tried to write to registers direct. on 12&14.

Is it correct in regard do PIN Pull down?