Search code examples
spiarduino-esp8266

SPI failing to work when the module it's powered on but works on WDT


Hardware

Hardware: ESP-12E (Node mcu like module it's actually Lolin)

Description

Disclaimer: Can jump right to the questions below.

Hello. I've flashed this NFC program set to work with SPI into the Lolin module but it doesn't work right away. Firstly it won't work with the usb cable connected that I can accept because maybe it might be sharing the same pins the SPI and USB. Another thing that is happening is that If I maintain the NFC module connected and press the reset button it shows some garbage in the serial output and it won't work unless I start with the NFC disconnected from the ESP module and wait for the serial output "Didn't find PN53x board" and then connect the NFC module and wait for the WDT reset at the line 30 in the infinite loop after the WDT reset the firmware it finally finds the NFC module and after that everything works as expected unless someone press the reset button (=P).

My question is shouldn't the reset button and the WDT reset cause the same effect even though one comes from hardware and another by software? So why by software the code starts to work? Does these SPI pins (GPIOs 14, 12, 13 and 15) need to be on a certain state when I power the module? How can I overcome this problem and maintain always the NFC module connected? There're SPI on the other side of the board can I use those as well?


Solution

  • The Hardware Chip Select (HCS) on GPIO15 also known as Master Data Output (MTDO) together with GPIO0 and GPIO2 is tied with the boot mode that depending on their states the module will boot up from UART, Flash and SD card. As I was using HCS to select the NFC module it was probably trying to boot up from the sd card hence the problem.