I am trying to understand the ESP32-S2 timers, their hardware and libraries to use. The problem is that I cannot find a detailed description of how the hardware works. I understand there are 4x64bit hardware timers, each capable of 16 separate event timers all from a common clock source. There is also a watchdog timer though I do not know if that is separate from the 4x64 hw timers. I understand there is a ULP (Ultra Low Power?) co-processor running an on chip Real Time Clock that needs a 32KHz oscillator or crystal. I cannot find the relevant parts in the datasheet (I'm sure that is included but where?). Chapter and para would be welcome.
On the software side, I have experimented with the timer examples in the Arduino libraries and, of course they work. But there seems to be different flavours of Arduino IDE library for the captioned microcntroller. They also seem to differ from Espressif's IDE library and thus I'm confused as to which is
At present, my application requires an Interrupt based one-shot timer which works. The problem is that after performing a rather long setup() (including PSRAM reads and writes which rely on a 5MHz SPI channel) the application crashes before entering loop(). The console log shows a watchdog timeout and I attach rather lengthy outputs from Serial Monitor and console log.
21:49:21.881 -> This is USBSerial.println
21:49:21.881 -> ---------------------------------------------------------------------------------
21:49:21.881 -> Initialisation Sequence started
21:49:21.881 -> ---------------------------------------------------------------------------------
21:49:21.881 -> Watchdog setup
21:49:21.881 -> PSRAM is correctly initialized
21:49:21.881 -> PSRAM Size available (bytes): 8384096
21:49:21.881 -> heap_caps_get_free_size(MALLOC_CAP_SPIRAM) : 8384096
21:49:21.881 -> heap_caps_get_free_size(MALLOC_CAP_INTERNAL) : 166572
21:49:21.881 -> heap_caps_get_free_size(MALLOC_CAP_DEFAULT) : 8550668
21:49:21.881 -> heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM) : 7733236
21:49:21.881 -> heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL) : 147444
21:49:21.881 -> heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT) : 7733236
21:49:21.881 ->
21:49:21.881 -> Entered DEV_SET_PWM
21:49:22.365 -> Entered RTC_DS3231_Init
21:49:22.365 ->
21:49:22.365 -> Start RTC_ESP on ESP32S2_DEV
21:49:22.365 -> Started RTC epoch = 0 or 0x0, seventyYears = 0 or 0x0
21:49:22.365 ->
21:49:22.365 -> Output of Struct tm: Thu 1970-01-01 00:00:00 - weekday 4; CW 00
21:49:22.365 -> 5 1-1-66 0:0:0 24h
21:49:22.397 -> eNTERED WiFi Setup
21:49:22.397 -> heap_caps_get_free_size(MALLOC_CAP_SPIRAM) : 8384096
21:49:22.397 -> heap_caps_get_free_size(MALLOC_CAP_INTERNAL) : 165200
21:49:22.397 -> heap_caps_get_free_size(MALLOC_CAP_DEFAULT) : 8549296
21:49:22.397 -> heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM) : 7733236
21:49:22.397 -> heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL) : 147444
21:49:22.397 -> heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT) : 7733236
21:49:22.397 ->
21:49:22.397 -> Connecting to REDACTED NETWORK NAME
21:49:22.429 -> .
21:49:22.687 -> You're connected to the network, IP = 192.168.0.36
21:49:22.817 -> Entered LCD_1IN14_Init(VERTICAL);
21:49:22.947 -> Set LCD_RST_PIN, true
21:49:23.043 -> Set LCD_RST_PIN, false
21:49:23.138 -> Set LCD_RST_PIN, true
21:49:23.138 -> Done LCD_1IN14_SetAttributes(uint8_t Scan_direction = 1) with LCD_1IN14_SendCommand(ST7789_MADCTL); followed by LCD_1IN14_SendData_8Bit(MemoryAccessReg = 0x0); LCD_1IN14.HEIGHT = 240, LCD_1IN14.WIDTH = 135
21:49:23.138 -> Done LCD_1IN14_SetAttributes(uint8_t Scan_direction = 1) with LCD_1IN14_SendCommand(ST7789_MADCTL); followed by LCD_1IN14_SendData_8Bit(MemoryAccessReg = 0x0); LCD_1IN14.HEIGHT = 240, LCD_1IN14.WIDTH = 135
21:49:23.138 -> Done LCD_1IN14_SetAttributes(uint8_t Scan_direction = 1) with LCD_1IN14_SendCommand(ST7789_MADCTL); followed by LCD_1IN14_SendData_8Bit(MemoryAccessReg = 0x0); LCD_1IN14.HEIGHT = 240, LCD_1IN14.WIDTH = 135
21:49:23.138 -> Done LCD_1IN14_SetAttributes(uint8_t Scan_direction = 1) with LCD_1IN14_SendCommand(ST7789_MADCTL); followed by LCD_1IN14_SendData_8Bit(MemoryAccessReg = 0x0); LCD_1IN14.HEIGHT = 240, LCD_1IN14.WIDTH = 135
21:49:23.138 -> Done LCD_1IN14_SetAttributes(uint8_t Scan_direction = 1) with LCD_1IN14_SendCommand(ST7789_MADCTL); followed by LCD_1IN14_SendData_8Bit(MemoryAccessReg = 0x0); LCD_1IN14.HEIGHT = 240, LCD_1IN14.WIDTH = 135
21:49:23.138 -> Done LCD_1IN14_SetAttributes(uint8_t Scan_direction = 1) with LCD_1IN14_SendCommand(ST7789_MADCTL); followed by LCD_1IN14_SendData_8Bit(MemoryAccessReg = 0x0); LCD_1IN14.HEIGHT = 240, LCD_1IN14.WIDTH = 135
21:49:23.138 -> LCD Init Done
21:49:23.138 -> heap_caps_get_free_size(MALLOC_CAP_SPIRAM) : 8367476
21:49:23.138 -> heap_caps_get_free_size(MALLOC_CAP_INTERNAL) : 127484
21:49:23.138 -> heap_caps_get_free_size(MALLOC_CAP_DEFAULT) : 8494960
21:49:23.138 -> heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM) : 7733236
21:49:23.138 -> heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL) : 118772
21:49:23.138 -> heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT) : 7733236
21:49:23.138 ->
21:49:23.138 -> Entered LCD_1IN14_Clear
21:49:26.372 -> Entered LCD_1in14_test
21:49:26.469 -> Entered LCD_1IN14_Init(VERTICAL);
21:49:26.565 -> Set LCD_RST_PIN, true
21:49:26.662 -> Set LCD_RST_PIN, false
21:49:26.758 -> Set LCD_RST_PIN, true
21:49:26.758 -> Done LCD_1IN14_SetAttributes(uint8_t Scan_direction = 0) with LCD_1IN14_SendCommand(ST7789_MADCTL); followed by LCD_1IN14_SendData_8Bit(MemoryAccessReg = 0x70); LCD_1IN14.HEIGHT = 135, LCD_1IN14.WIDTH = 240
21:49:26.758 -> Done LCD_1IN14_SetAttributes(uint8_t Scan_direction = 0) with LCD_1IN14_SendCommand(ST7789_MADCTL); followed by LCD_1IN14_SendData_8Bit(MemoryAccessReg = 0x70); LCD_1IN14.HEIGHT = 135, LCD_1IN14.WIDTH = 240
21:49:26.758 -> Done LCD_1IN14_SetAttributes(uint8_t Scan_direction = 0) with LCD_1IN14_SendCommand(ST7789_MADCTL); followed by LCD_1IN14_SendData_8Bit(MemoryAccessReg = 0x70); LCD_1IN14.HEIGHT = 135, LCD_1IN14.WIDTH = 240
21:49:26.758 -> Done LCD_1IN14_SetAttributes(uint8_t Scan_direction = 0) with LCD_1IN14_SendCommand(ST7789_MADCTL); followed by LCD_1IN14_SendData_8Bit(MemoryAccessReg = 0x70); LCD_1IN14.HEIGHT = 135, LCD_1IN14.WIDTH = 240
21:49:26.758 -> Done LCD_1IN14_SetAttributes(uint8_t Scan_direction = 0) with LCD_1IN14_SendCommand(ST7789_MADCTL); followed by LCD_1IN14_SendData_8Bit(MemoryAccessReg = 0x70); LCD_1IN14.HEIGHT = 135, LCD_1IN14.WIDTH = 240
21:49:26.758 -> Done LCD_1IN14_SetAttributes(uint8_t Scan_direction = 0) with LCD_1IN14_SendCommand(ST7789_MADCTL); followed by LCD_1IN14_SendData_8Bit(MemoryAccessReg = 0x70); LCD_1IN14.HEIGHT = 135, LCD_1IN14.WIDTH = 240
21:49:26.758 -> Entered LCD_1IN14_Clear
21:49:29.990 -> BlackImage is now pointing to: 0x3F505384
21:49:29.990 -> BlackImage's number of octets: 64800
21:49:29.990 -> heap_caps_get_free_size(MALLOC_CAP_SPIRAM) : 8302660
21:49:29.990 -> heap_caps_get_free_size(MALLOC_CAP_INTERNAL) : 127484
21:49:29.990 -> heap_caps_get_free_size(MALLOC_CAP_DEFAULT) : 8430144
21:49:29.990 -> heap_caps_get_largest_free_block(MALLOC_CAP_SPIRAM) : 7733236
21:49:29.990 -> heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL) : 118772
21:49:29.990 -> heap_caps_get_largest_free_block(MALLOC_CAP_DEFAULT) : 7733236
21:49:29.990 ->
21:49:30.506 -> 2.Drawing on the image
21:49:30.538 -> 3.Refresh the picture in RAM to LCD
21:49:31.603 -> 2.Drawing on the image
21:49:31.603 -> 3.Refresh the picture in RAM to LCD
21:49:32.671 -> 2.Drawing on the image
21:49:32.671 -> 3.Refresh the picture in RAM to LCD
21:49:33.736 -> 2.Drawing on the image
21:49:33.736 -> 3.Refresh the picture in RAM to LCD
21:49:34.802 -> 2.Drawing on the image
21:49:34.802 -> 3.Refresh the picture in RAM to LCD
21:49:35.868 -> 2.Drawing on the image
21:49:35.868 -> 3.Refresh the picture in RAM to LCD
21:49:36.903 -> Painting contents of imageData.c
21:50:14.836 -> Exit from button/joystick test...
21:50:14.836 -> End of setup()
And reboot/repeat
From Console:-
=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2023.10.29 21:49:01 =~=~=~=~=~=~=~=~=~=~=~=
This is HWSerial.println
[92051279][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[92051779][I][esp32-hal-i2c.c:99] i2cInit(): Initialising I2C Master: sda=14 scl=15 freq=400000
[92051798][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 0 - WIFI_READY
[92051837][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 2 - STA_START
[92051883][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[92052897][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[92052898][D][WiFiGeneric.cpp:1102] _eventCallback(): STA IP: 192.168.0.36, MASK: 255.255.255.0, GW: 192.168.0.253
[92053231][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[92053331][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[92053432][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[92053544][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[92056858][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[92056959][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[92057059][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[92057172][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
This is HWSerial.println
[ 7496][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 7997][I][esp32-hal-i2c.c:99] i2cInit(): Initialising I2C Master: sda=14 scl=15 freq=400000
[ 8015][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 0 - WIFI_READY
[ 8053][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 2 - STA_START
[ 8070][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[ 8070][W][WiFiGeneric.cpp:1064] _eventCallback(): Reason: 202 - AUTH_FAIL
[ 8074][D][WiFiGeneric.cpp:1084] _eventCallback(): WiFi Reconnect Running
[ 8130][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[ 8142][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[ 8142][D][WiFiGeneric.cpp:1102] _eventCallback(): STA IP: 192.168.0.36, MASK: 255.255.255.0, GW: 192.168.0.253
[ 8454][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 8555][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 8656][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 8768][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 12079][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 12180][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 12281][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 12393][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
Total Size : 201176 B ( 196.5 KB)
Free Bytes : 127484 B ( 124.5 KB)
Allocated Bytes : 67736 B ( 66.1 KB)
Minimum Free Bytes: 125896 B ( 122.9 KB)
Largest Free Block: 118772 B ( 116.0 KB)
------------------------------------------
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
Core 0 register dump:
PC : 0x4011ed61 PS : 0x00060834 A0 : 0x8011ec3b A1 : 0x3ffd77d0
A2 : 0x3f5150a4 A3 : 0x4011ec78 A4 : 0x3ffd7834 A5 : 0x3f5150a8
A6 : 0xfffffffc A7 : 0xffffffff A8 : 0xffffffff A9 : 0x3ffd77b0
A10 : 0x3f5150ac A11 : 0xfffffffc A12 : 0x00000000 A13 : 0x3ffd7834
A14 : 0x3ffd75fc A15 : 0x3ffd7720 SAR : 0x00000006 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x00000000 LEND : 0x3ffd7834 LCOUNT : 0x4002718c
Backtrace: 0x4011ed5e:0x3ffd77d0 0x4011ec38:0x3ffd77f0 0x4011ecc5:0x3ffd7810 0x4009955e:0x3ffd7830 0x4008f1ba:0x3ffd7870 0x4008f713:0x3ffd78b0 0x4008f036:0x3ffd78d0
ELF file SHA256: ff7ab00d941eb371
Rebooting...
ESP-ROM:esp32s2-rc4-20191025
Build:Oct 25 2019
rst:0xc (RTC_SW_CPU_RST),boot:0xb (SPI_FAST_FLASH_BOOT)
Saved PC:0x4002733a
SPIWP:0xee
mode:DIO, clock div:1
load:0x3ffe6110,len:0x578
load:0x4004b000,len:0x4
load:0x4004b004,len:0x978
load:0x4004f000,len:0x2d70
entry 0x4004b138
[ 61183][D][esp32-hal-tinyusb.c:695] tinyusb_enable_interface(): Interface CDC enabled
[ 61184][D][esp32-hal-tinyusb.c:584] tinyusb_load_enabled_interfaces(): Load Done: if_num: 2, descr_len: 75, if_mask: 0x10
[ 62030][I][esp32-hal-psram.c:92] psramInit(): PSRAM enabled
=========== Before Setup Start ===========
Chip Info:
------------------------------------------
Model : ESP32-S2
Package : 0
Revision : 0
Cores : 1
Frequency : 240 MHz
Embedded Flash : No
Embedded PSRAM : No
2.4GHz WiFi : Yes
Classic BT : No
BT Low Energy : No
IEEE 802.15.4 : No
------------------------------------------
INTERNAL Memory Info:
------------------------------------------
Total Size : 201176 B ( 196.5 KB)
Free Bytes : 168884 B ( 164.9 KB)
Allocated Bytes : 29240 B ( 28.6 KB)
Minimum Free Bytes: 163856 B ( 160.0 KB)
Largest Free Block: 147444 B ( 144.0 KB)
------------------------------------------
SPIRAM Memory Info:
------------------------------------------
Total Size : 8388608 B (8192.0 KB)
Free Bytes : 8384512 B (8188.0 KB)
Allocated Bytes : 0 B ( 0.0 KB)
Minimum Free Bytes: 8384512 B (8188.0 KB)
Largest Free Block: 7733236 B (7552.0 KB)
Bus Mode : QSPI
------------------------------------------
Flash Info:
------------------------------------------
Chip Size : 4194304 B (4 MB)
Block Size : 65536 B ( 64.0 KB)
Sector Size : 4096 B ( 4.0 KB)
Page Size : 256 B ( 0.2 KB)
Bus Speed : 80 MHz
Bus Mode : QIO
------------------------------------------
Partitions Info:
------------------------------------------
nvs : addr: 0x00009000, size: 20.0 KB, type: DATA, subtype: NVS
otadata : addr: 0x0000E000, size: 8.0 KB, type: DATA, subtype: OTA
app0 : addr: 0x00010000, size: 3072.0 KB, type: APP, subtype: OTA_0
spiffs : addr: 0x00310000, size: 896.0 KB, type: DATA, subtype: SPIFFS
coredump : addr: 0x003F0000, size: 64.0 KB, type: DATA, subtype: COREDUMP
------------------------------------------
Software Info:
------------------------------------------
Compile Date/Time : Oct 25 2023 19:18:30
Compile Host OS : linux
ESP-IDF Version : v5.1.1-577-g6b1f40b9bf-dirty
Arduino Version : 3.0.0
------------------------------------------
Board Info:
------------------------------------------
Arduino Board : ESP32S2_DEV
Arduino Variant : esp32s2
Arduino FQBN : esp32:esp32:esp32s2:UploadSpeed=921600,CDCOnBoot=cdc,MSCOnBoot=default,DFUOnBoot=default,UploadMode=cdc,CPUFreq=240,FlashFreq=80,FlashMode=qio,FlashSize=4M,PartitionScheme=huge_app,DebugLevel=debug,PSRAM=enabled,EraseFlash=none,JTAGAdapter=default
============ Before Setup End ============
E (27This is HWSerial.println
[ 67403][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 67904][I][esp32-hal-i2c.c:99] i2cInit(): Initialising I2C Master: sda=14 scl=15 freq=400000
[ 67922][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 0 - WIFI_READY
[ 67960][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 2 - STA_START
[ 67977][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED
[ 67977][W][WiFiGeneric.cpp:1064] _eventCallback(): Reason: 202 - AUTH_FAIL
[ 67980][D][WiFiGeneric.cpp:1084] _eventCallback(): WiFi Reconnect Running
[ 68037][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[ 68049][D][WiFiGeneric.cpp:1042] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[ 68050][D][WiFiGeneric.cpp:1102] _eventCallback(): STA IP: 192.168.0.36, MASK: 255.255.255.0, GW: 192.168.0.253
[ 68346][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 68447][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 68547][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 68660][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 71973][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 72073][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 72174][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
[ 72286][E][esp32-hal-gpio.c:167] __digitalWrite(): Pin is not set as GPIO.
=========== After Setup Start ============
INTERNAL Memory Info:
------------------------------------------
Total Size : 201176 B ( 196.5 KB)
Free Bytes : 127480 B ( 124.5 KB)
Allocated Bytes : 67740 B ( 66.2 KB)
Minimum Free Bytes: 125892 B ( 122.9 KB)
Largest Free Block: 118772 B ( 116.0 KB)
------------------------------------------
Guru Meditation Error: Core 0 panic'ed (Interrupt wdt timeout on CPU0).
Core 0 register dump:
PC : 0x4011ec8c PS : 0x00060834 A0 : 0x8011ed5a A1 : 0x3ffd77b0
A2 : 0x3f5150ac A3 : 0xfffffffc A4 : 0x00000000 A5 : 0x3ffd7834
A6 : 0x3ffd75fc A7 : 0x3ffd7720 A8 : 0x0013f597 A9 : 0x3ffc8f0c
A10 : 0x00060820 A11 : 0x00000001 A12 : 0x00060021 A13 : 0x00000000
A14 : 0x3ffc8bdc A15 : 0x3ffd76e0 SAR : 0x00000006 EXCCAUSE: 0x00000005
EXCVADDR: 0x00000000 LBEG : 0x00060021 LEND : 0x00000000 LCOUNT : 0x4002718c
Backtrace: 0x4011ec89:0x3ffd77b0 0x4011ed57:0x3ffd77d0 0x4011ec38:0x3ffd77f0 0x4011ecc5:0x3ffd7810 0x4009955e:0x3ffd7830 0x4008f1ba:0x3ffd7870 0x4008f713:0x3ffd78b0 0x4008f036:0x3ffd78d0
ELF file SHA256: ff7ab00d941eb371
Rebooting
...
Sorry about the lengthy post but I am confused as to why my app reboots and what is the optimum library to use?