ESP32-S2 Timers and Timer Interrupts - Using Arduino IDE2

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?

Give the ESP32 Technical Reference a try: https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf

thinking this
ESP32 High Resolution Timer
is worth a read as well..
did a quick messy simm a while back..
timer blink led

don't see how..

has anything to do with a timer though??
looks like maybe an issue with the pins used for I2C??

good luck.. ~q

have a look at ESP32TimerInterrupt and Espressif Timer

Thanks, I now have a copy of that manual - all 847 pages! As usual for tech manuals, it is full of Jargon and you have to look up different pages to find out what the various tokens are. I can see that apart from the timer group in chapter 11, there is a system timer in chapter 10 which I didn't know about, and of course, the ULP coprocessor with RTC etc in earlier chapters. Whew! I'm still confused at the moment.

1 Like

Thanks Yes, I need the good luck! I have the ESP32-S2 version of the API for Arduino open at the moment and I'm trying to follow that. I will be doing stand-alone experiments shortly. The One-Shot example looks remarkedly like the one I have implemented which suggests we are getting info from the same source. And that bit works. The i2c tip is something I need to look at, I do set up i2C for a DS3231 and a BME280 on the board I'm using.

#define DEV_SDA_PIN     GPIO14
#define DEV_SCL_PIN     GPIO15

The pity is that the GPIO reports do not indicate which physical port has a problem or if the issues are from the internal port setup matrix? In practice, the devices i2c/SPI/GPIO ports seem to work OK so I'm thinking that this is an initial report before the setup potion of my app takes effect - but I stand to be corrected!

Thanks for your input. Tony

1 Like

I have used a BME280 running the ErriezBMX280 example on an ESP32 using the default I2C pins and address

ErriezBMX280 bmx280 = ErriezBMX280(0x76);

results

18:47:06.421 -> Erriez BMP280/BMX280 example
18:47:06.559 -> 
18:47:06.559 -> Sensor type: BME280
18:47:06.559 -> 
18:47:06.559 -> Temperature: 22.18 C
18:47:06.559 -> Humidity:    46.69 %
18:47:06.559 -> Pressure:    1021.06 hPa
18:47:06.559 -> Altitude:    42.76 m
18:47:06.559 -> 
18:47:07.550 -> Temperature: 22.23 C
18:47:07.550 -> Humidity:    46.65 %
18:47:07.550 -> Pressure:    1021.05 hPa
18:47:07.550 -> Altitude:    42.84 m

I have also used the Adafruit_BME280_Library

1 Like

Thanks for the input. I did look at the libraries indicated by your link when I was first trying out timers and I'm currently trying to use the ESP32-S2 version of that library. I do not find it clear whether I should be using the ESP32_S2_TimerInterrupt or ESP32_New_TimerInterrupt library versions. I already have the link to the Espressif Timer API for Arduino open. So much information available but finding the needle I want in the haystack of words/jargon is eluding me for the time being.

Thanks for the info. I do NOT have a problem with the BME280 and I have used the ESP32 (not ESP32-S2) in my home automation system. I know the i2c works from my ESP32-S2 in the current app I'm working on. My problem is with (I think) timers, in particular a watchdog timer, which is causing a reboot after 'setup()'..

I don't have an ESP32-S2 but my ESP32-S3-DevKitC-1 runs File>Examples>ESP32>Timer>RepeatTimer OK, e.g.

onTimer no. 1 at 1096 ms
onTimer no. 2 at 2096 ms
onTimer no. 3 at 3096 ms
onTimer no. 4 at 4096 ms
onTimer no. 5 at 5096 ms
onTimer no. 6 at 6096 ms
onTimer no. 7 at 7096 ms
onTimer no. 8 at 8096 ms
onTimer no. 9 at 9096 ms
onTimer no. 10 at 10096 ms
onTimer no. 11 at 11096 ms
onTimer no. 12 at 12096 ms
onTimer no. 13 at 13096 ms
onTimer no. 14 at 14096 ms
onTimer no. 15 at 15096 ms
onTimer no. 16 at 16096 ms
onTimer no. 17 at 17096 ms

the watchdog timer is reset if you stay in a loop or section of code too long, 10 seconds
use printf statements to show the flow of the code to the point where the WDT resets

@horace Yes, the WDT will reset if events take too long. I read in the Espressif documents that using PSRAM, as I do, may cause WDT timeouts. This is because the SPI transmission speed for long PSRAM read/write may take longer than the allowed WDT interval. I am writing and reading 64800 octets to PSRAM which, at the 5MHz SPI clock will take (64800*8)*200 Microseconds plus overheads each time for six LCDs.. Although the data gets written (once) and susequently read six times sucessfully, the system resets anyway.

I did tinker with timer watchdog examples from the library and these worked as they should. Lengthening the WDT time delay stopped WDT resets in the examples as expected but ding the same for my app still caused resets. The thing is, with two WDT's in the timer group plus the ULP-RTC WDT, I don't know which one is resetting my app.

That is, of course, I'm not following a wild goose chase and it is something completely different! :thinking:

I have to put things on hold for the time being as I have had a power supply failure affecting the street. As usual, a power surge has crippled a PSU - a different one again - and lots of stuff has gone offline and needs nursing back to normality. Sigh! Tony

on reset you can call esp_reset_reason() to determine the cause, e.g. powerON, WDT timeout, brownout, etc
e.g. a version I use

// print and return reason for system reset
// see https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/misc_system_api.html#_CPPv418esp_reset_reason_t
int print_reset_reason(void) {
  int reason = esp_reset_reason();
  Serial.printf("CPU reset reason: %d ", reason);
  switch (reason) {
    case ESP_RST_UNKNOWN: Serial.println("unknown_RESET"); break;
    case ESP_RST_POWERON: Serial.println("POWERON_RESET"); break;
    case ESP_RST_SW: Serial.println("SW_RESET"); break;
    case ESP_RST_PANIC: Serial.println("PANIC_RESET"); break;
    //case ESP_RST_INT_WD: Serial.println("INTERRUPT_WDT_RESET"); break;
    case ESP_RST_TASK_WDT: Serial.println("TASK_WDT_RESET"); break;
    case ESP_RST_WDT: Serial.println("OTHER_WDT_RESET"); break;
    case ESP_RST_DEEPSLEEP: Serial.println("EXIT_DEEP_SLEEP_RESET"); break;
    case ESP_RST_BROWNOUT: Serial.println("BROWNOUT_RESET"); break;
    case ESP_RST_SDIO:
      Serial.println("SDIO_RESET");
      break;
      //case ESP_RST_USB: Serial.println("USB_RESET"); break;
  }
  return reason;
}

if you are in a loop and for some reason need to reset the WDT you can call esp_task_wdt_reset() - for more information see ESP32 watchdogs

@horace Thanks for that useful bit of code. I can use that for debugging.

Sorry about the long time answering but I have had yet another supply disruption but fortunately not so damaging. I have also been updating my old Pi's to Bookworm which has taken a lot of effort.

I have now read a bit more about WatchDogs in the ESP32-S2 and it seems that there are two principal TYPES of watchdog. One, known as Interrupt WatchDog Timer (IWDT) which handles infinite loops and hardware stalls, and the Task WatchDog Timer (TWDT) which is a user task fault handler. Further there seems to be code variants for Espressif's ESP-IDF and the Arduino based libraries. It is very confusing to my old grey cells! I have experimented with some LED's and push buttons to simulate different timers and a watchdog test case. That is before I saw your code above though.

I think for continuing my development, I will disable all watchdogs until I'm happy with my code. I wish the Arduino IDE 2.1.x had a breakpointing system built in and there was a suitable description of how to use the JTAG facility therein. I found an old Amontec USB to JTAG adaptor that I bought eons ago (and forgotten) when tinkering with Marvell Arm based processors.

Sorry, I'm rambling now.... Thanks again for your input,
Cheers Tony

the target ESP32 would require a JTAG port - see ESP-WROVER-KIT V4.1
don't know any low cost ESP32 dev boards which supports JTAG

not sure how well the Arduino IDE supports JTAG
Espressif's ESP-IDF does - see jtag-debugging

Fortunately the pins on the Waveshare ESP32-S2_Pico board brings out the JTAG assigned pins (GPIO39-42) to available pins and even more fortunately, the target board does not utilise those pins. Yes, GPIO40/41 are assigned to alternate i2c0 but I don't use them.

I don't think Aduino IDE2 supports JTAG but creating a binary (.elf?) file should allow OpenOCD to work independently. Maybe I should switch to Visual Studio which is resident on my (Linux) system, but that is yet another learning curve.

I havn't had the time to sort out the JTAG interface for OpenOCD yet and I think that it will take some digging around in my old memory banks to remember how to works things again - it is at least 10 years since I played JTAG!

I think it is longer than that since I last used JTAG - again on ARMs
tend to just used printf() statements to display variable values and show program logic flow
latest ESP32 custom PCB has a JTAG connector - found no requirement to use it so far

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.