Skip to content

pinMode() on pin 13 causes watchdog reset and CPU freezes afterwards! #801

Closed
@vishnumaiea

Description

@vishnumaiea

Hardware:

Board: NodeMCU-32S
USB Chip: CH340G
Core Installation/update date: A week ago
IDE name: Arduino IDE 1.8.5
CPU Frequency: 240MHz
Flash Frequency: 80Mhz
Upload Speed: 921600
OS: Windows 7 64bit
Power Source: USB

Description:

I'm trying to interface a 3.2" TFT LCD display to ESP32 (NodeMCU-32S). I need 8 + 4 pins for parallel interface. So defined the pins and set all of them as OUPUT using the pinMode() in setup() function. The code compiles and uploads successfully. But as soon as the execution reaches the pinMode() function, the system gets reset and after a few resets, the CPU freezes. You can see in the serial output window that the next event after printing the "Initializing..." message is a reset. The loop() function never gets executed after the reset (obviously).

If I comment out the pinMode() line, everything works fine.

Update (5:59PM, 01-11-2017): Apparently, this only happens when trying to set pin 13. It works fine for all other pins.

Sketch:

A part of the code is given below

#define CS_PIN 13
#define RST_PIN 12
#define DC_PIN 14
#define WR_PIN 27

#define PD0 15 //parallel data pins
#define PD1 2
#define PD2 0
#define PD3 4
#define PD4 16
#define PD5 17
#define PD6 21
#define PD7 22

void setup() {
  Serial.begin (115200);
  Serial.print("CPU Clock = ");
  Serial.println(ESP.getCpuFreqMHz());
  Serial.println ("Initializing...");

  pinMode (CS_PIN, OUTPUT); //set all pins as outputs
  // pinMode (RST_PIN, OUTPUT);
  // pinMode (DC_PIN, OUTPUT);
  // pinMode (WR_PIN, OUTPUT);
  // pinMode (PD0, OUTPUT);
  // pinMode (PD1, OUTPUT);
  // pinMode (PD2, OUTPUT);
  // pinMode (PD3, OUTPUT);
  // pinMode (PD4, OUTPUT);
  // pinMode (PD5, OUTPUT);
  // pinMode (PD6, OUTPUT);
  // pinMode (PD7, OUTPUT);
}

void loop() {
  Serial.println ("Working..");
  Serial.print ("CPU Clock = ");
  Serial.println (ESP.getCpuFreqMHz());
  delay(500);
}

Serial output:

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:812
load:0x40078000,len:0
load:0x40078000,len:10212
entry 0x40078a00
CPU Clock = 240
Initializing...
ets Jun  8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:812
load:0x40078000,len:0
load:0x40078000,len:10212
entry 0x40078a00
CPU Clock = 240
Initializing...
ets Jun  8 2016 00:22:57

Build console output when uploading:

Sketch uses 140170 bytes (10%) of program storage space. Maximum is 1310720 bytes.
Global variables use 11084 bytes (3%) of dynamic memory, leaving 283828 bytes for local variables. Maximum is 294912 bytes.
esptool.py v2.1
Connecting........__
Chip is ESP32D0WDQ6 (revision 0)
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 921600
Changed.
Configuring flash size...
Auto-detected Flash size: 4MB
Compressed 8192 bytes to 47...

Writing at 0x0000e000... (100 %)
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.0 seconds...
Hash of data verified.
Flash params set to 0x022f
Compressed 11120 bytes to 7467...

Writing at 0x00001000... (100 %)
Wrote 11120 bytes (7467 compressed) at 0x00001000 in 0.1 seconds (effective 967.0 kbit/s)...
Hash of data verified.
Compressed 141312 bytes to 79541...

Writing at 0x00010000... (20 %)
Writing at 0x00014000... (40 %)
Writing at 0x00018000... (60 %)
Writing at 0x0001c000... (80 %)
Writing at 0x00020000... (100 %)
Wrote 141312 bytes (79541 compressed) at 0x00010000 in 1.2 seconds (effective 942.9 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 122...

Writing at 0x00008000... (100 %)
Wrote 3072 bytes (122 compressed) at 0x00008000 in 0.0 seconds...
Hash of data verified.

Leaving...
Hard resetting...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions