-->
Page 1 of 1

Using GPIO2 for led or something with low resistance boot

PostPosted: Sat Apr 30, 2016 8:22 am
by CROSP
Hi, I have almost finished my project, but I have noticed one problem. It is clear why does it happen, but I wan't to solve it in some way.

I am using two GPIOs on my board. They are toggling periodically, for instance for switching leds.
Just to mention, that everything works still fine except some problems with GPIOs.

So I am toggling leds and when I switch on led on GPIO2 modules goes into boot mode, but again still responds to requests.

Here is output from serial port.

Code: Select allTCP: data received 76 bytes
MQTT: Received data on topic: /wh/home/hallway/communication/intercom
TYPE IS : command
Got COMMAND
NEXT IS PAIR VALUE
VALUE IS : on
OPEN INTERCOM
ets Jan 8 2013,rst cause:2, boot mode:(3,7)
load 0x40100000, len 29356, room 16


As you can see after turning on (making low resistance between GND and GPIO2 because of LED) it switches to the boot mode or at least writes this stuff to serial and after this it doesn't show any debug data on serial port, but still works fine.

Here is my initialization of GPIOs

Code: Select all#define REED_GPIO 2
#define REED_GPIO_MUX PERIPHS_IO_MUX_GPIO2_U
#define REED_GPIO_FUNC FUNC_GPIO2
 
#define BUTTON_GPIO 0
#define BUTTON_GPIO_MUX PERIPHS_IO_MUX_GPIO0_U
#define BUTTON_GPIO_FUNC FUNC_GPIO0
 
void ICACHE_FLASH_ATTR
gpio_init() {
    // Configure reed (relay)
    PIN_FUNC_SELECT(REED_GPIO_MUX, REED_GPIO_FUNC);
    GPIO_OUTPUT_SET(REED_GPIO, 0);
    // Configure button
    PIN_FUNC_SELECT(BUTTON_GPIO_MUX, BUTTON_GPIO_FUNC);
    GPIO_OUTPUT_SET(BUTTON_GPIO, 0);
}
 
void ICACHE_FLASH_ATTR open_intercom() {
    GPIO_OUTPUT_SET(REED_GPIO, 0);
    os_delay_us(DELAY_CLICK);
    GPIO_OUTPUT_SET(BUTTON_GPIO, 1);
    os_delay_us(DELAY_CLICK*2);
    close_intercom();
}
void ICACHE_FLASH_ATTR close_intercom() {
    GPIO_OUTPUT_SET(REED_GPIO, 1);
    os_delay_us(DELAY_CLICK);
    GPIO_OUTPUT_SET(BUTTON_GPIO, 0);
    os_delay_us(DELAY_CLICK);
}


SO I have two questions

1. Is it okay if during lifecycle (loop) of the module I switch sometime GPIO2 to GND through low resistance component, or there is any other way how can I solve this programmatically. Or there is only one options connecting led reversely

Image


2. And the most important question whether I set up GPIOs correctly and using them correctly ? I just copied from and example, so I am not sure if gpios are used correctly ? It is working, but when I try to switch LED sometimes GPIO0 blinks several times and than lights normally, I think this is because of going into bootmode after switching GPIO2 led.

Thanks.