ESP12-F Unable to activate HSPI - Causing watchdog reset
Posted: Thu Apr 11, 2024 7:13 pm
Hi, i'm struggling tu use HSPI on ESP8266 (ESP12-F / NONOS / SDK 3.0.5). For the SPI part, i use the following code grabbed on GitHub
----------------------------------------------------
if(spi_no==SPI){
WRITE_PERI_REG(PERIPHS_IO_MUX, 0x005|(clock_div_flag<<8)); //Set bit 8 if 80MHz sysclock required
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, 1);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CMD_U, 1);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA0_U, 1);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA1_U, 1);
}else if(spi_no==HSPI){
WRITE_PERI_REG(PERIPHS_IO_MUX, 0x105|(clock_div_flag<<9)); //Set bit 9 if 80MHz sysclock required
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, 2); //GPIO12 is HSPI MISO pin (Master Data In)
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, 2); //GPIO13 is HSPI MOSI pin (Master Data Out)
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, 2); //GPIO14 is HSPI CLK pin (Clock)
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, 2); //GPIO15 is HSPI CS pin (Chip Select / Slave Select)
}
--------------------------------------------------
I would like to set up the HSPI clock to a few MHz so i think, according to the comments, that 0x105 is the correct value to write in the PERIPHS_IO_MUX register.
My code starts whitout issue, displaying various strings on UART output but, as soon as i write 0x105 in PERIPHS_IO_MUX during the HSPI initialization phase, the program hangs causing a watchdog reset.
1) I checked (and even changed) the power supply and its OK (220µF + 100nF in // on Vcc)
2) I also tried to write 0x305 -> same behavior (reset)
3) I tried to read the value at @PERIPHS_IO_MUX and i got 0x205 ( 80MHz on HSPI ?). Then writing back 0x205 at the same address is OK -> not a memory access issue. I checked SCLK pin with an oscilloscope -> no clock
4) I tried a second ESP12-F chip -> same behavior (reset)
One thing a little bit strange for me : according to the code and comments, the value of 0x105 can program two differents configurations: HSPI with clock<80MHz but also SPI with clock=80Mhz. Which one is correct ?
I've been searching on Internet for days and found nothing similar to this very basic issue...
Any idea or suggestion are welcome.
----------------------------------------------------
if(spi_no==SPI){
WRITE_PERI_REG(PERIPHS_IO_MUX, 0x005|(clock_div_flag<<8)); //Set bit 8 if 80MHz sysclock required
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, 1);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CMD_U, 1);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA0_U, 1);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_DATA1_U, 1);
}else if(spi_no==HSPI){
WRITE_PERI_REG(PERIPHS_IO_MUX, 0x105|(clock_div_flag<<9)); //Set bit 9 if 80MHz sysclock required
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDI_U, 2); //GPIO12 is HSPI MISO pin (Master Data In)
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, 2); //GPIO13 is HSPI MOSI pin (Master Data Out)
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTMS_U, 2); //GPIO14 is HSPI CLK pin (Clock)
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, 2); //GPIO15 is HSPI CS pin (Chip Select / Slave Select)
}
--------------------------------------------------
I would like to set up the HSPI clock to a few MHz so i think, according to the comments, that 0x105 is the correct value to write in the PERIPHS_IO_MUX register.
My code starts whitout issue, displaying various strings on UART output but, as soon as i write 0x105 in PERIPHS_IO_MUX during the HSPI initialization phase, the program hangs causing a watchdog reset.
1) I checked (and even changed) the power supply and its OK (220µF + 100nF in // on Vcc)
2) I also tried to write 0x305 -> same behavior (reset)
3) I tried to read the value at @PERIPHS_IO_MUX and i got 0x205 ( 80MHz on HSPI ?). Then writing back 0x205 at the same address is OK -> not a memory access issue. I checked SCLK pin with an oscilloscope -> no clock
4) I tried a second ESP12-F chip -> same behavior (reset)
One thing a little bit strange for me : according to the code and comments, the value of 0x105 can program two differents configurations: HSPI with clock<80MHz but also SPI with clock=80Mhz. Which one is correct ?
I've been searching on Internet for days and found nothing similar to this very basic issue...
Any idea or suggestion are welcome.