Use of GPIO0 and GPIO2 on ESP-01

glins
Posts: 1
Joined: Fri Nov 11, 2016 1:15 am

Use of GPIO0 and GPIO2 on ESP-01

Postby glins » Tue Dec 06, 2016 10:55 am

Hi, you all!
I've been working with the esp8266 module for a few days now, and I am honestly amazed.

Since the esp module I'm using only has two GPIOs, I have a microcontroller that will send analog data to the esp, which will again send that data to a tcp server. Almost all of the above are working quite fine, except I cant get any of the GPIO's to read anything, not even digital data.

Browsing this forum, I tried implementing the following suggestion, but without any success. I need your help.
Thanks for everyone reading this :)


Code: Select all

void ICACHE_FLASH_ATTR
gpio_init(void)
{
    PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U,FUNC_GPIO0);                //GPIO Alternate Function
    GPIO_DIS_OUTPUT(GPIO_ID_PIN(0));                                  //Configure it in input mode.
    ETS_GPIO_INTR_DISABLE();                                           //Close the GPIO interrupt
    ETS_GPIO_INTR_ATTACH(GPIO_INTERRUPT,NULL);                         //Register the interrupt function
    gpio_pin_intr_state_set(GPIO_ID_PIN(0),GPIO_PIN_INTR_NEGEDGE);    //Falling edge trigger
    ETS_GPIO_INTR_ENABLE() ;                                           //Enable the GPIO interrupt
}


I then created the GPIO_INTERRUPT function that basically only printed a message. It does print when I set GPIO0 to 0, but then the device restarts. Sigh. It's the non-os version.
Any hints?

pratik

Re: Use of GPIO0 and GPIO2 on ESP-01

Postby pratik » Mon Dec 12, 2016 12:55 pm

Hi!
Please add your GPIO interrupt handler code.
Make sure its attribute is either IRAM_ATTR or no attribute at all. But interrupts must not be ICACHE_FLASH_ATTR!

Who is online

Users browsing this forum: No registered users and 56 guests