-->
Page 1 of 1

ESP 12F SPI pins as GPIO

PostPosted: Wed Apr 20, 2016 9:31 pm
by Nimit Vachhani
Greetings Everybody,

ESP 12F has miso , mosi and sck pins for spi communications, can i use these pins as digital IOs ? I use Android IDE for programming. Any advice will be helpful.

Re: ESP 12F SPI pins as GPIO

PostPosted: Thu Apr 21, 2016 7:54 am
by picstart
I don't have a 12f but with the 12E the gpio 9 and gpio 10 are used by the flash for QIO. The pins are under the can. For the 12E i remove the can and lift the pins 3 and 7
/// pin 3 is wired to 7 and then to 3.3v
/// +--------+
/// _CS |1 8| 3.3v
/// DO |2 7| _HOLD
/// _WP |3 6| CLK
/// GND |4 5| DI
/// +--------+
/// 25Q32 4m byte flash
next in arduino IDE setup move the pin to function 3 mode after that you can use it as GPIO
pinMode(SD_CS,FUNCTION_3); //// needed since GPIO9 is function 3
pinMode(SD_CS, OUTPUT);

QIO is faster than DIO when using flash but in practice the difference isn't noticeable when flashing or running

Re: ESP 12F SPI pins as GPIO

PostPosted: Sun May 22, 2016 3:09 pm
by coldpenguin
Some sites state the in order to use GPIO10 and GPIO09 you must physically remove their connections to the flash chip.

I have managed to write code which has not needed this modification. Your mileage may vary.

Set the flash type to DIO. Write code and use the port in such a way that in general GPIO10 is high. This is connected to write-protect, so most of the time it doesn't matter (if you are using SPIFFS you might care more).

For GPIO09 you have to be a LOT more careful. This is effectively another chip-enable for the flash.
You must make sure it is high whenever the flash is required.
Make sure that any function which uses/sets GPIO09 is ICACHE_RAM and that GPIO09 is high otherwise.
If you use OTA, or intend to flash the chip 'randomly' you must ensure that the pin fails HIGH.

With this limitation it does restrict the usefulness of the pin, however something like I2C or SPI on the port is more than possible.

Re: ESP 12F SPI pins as GPIO

PostPosted: Sun May 22, 2016 5:54 pm
by Barnabybear
Hi, unless you need serial why not use GPIOs 1 & 3 (Tx & Rx) much less work.