I've been working with the ESP32 for nearly a year, but this is my first larger project. I've designed a seesaw, and I want to control it, and monitor the variables on the PC.
On the ESP side i'm using a timer interrupt to read the values from an MPU6050 IMU, apply a Kalman filter for the angle denoising. Then I'm using a PID control to generate a duty cycle value, which is fed into the LEDC pwm peripheral. A TCP based MQTT handler is running on another thread, which receives and sends data to/from the PC.
On the PC side I'm using mosquitto broker and node-red to set the control reference, PID coefficients, and to read some angle values.
Everything works separately. I can set the PWM values, I can send and receive PID coeffs, and angle values. The moment I enable the timer interrupt, and I try to send some values to the ESP, I get some strange error messages:
Code: Select all
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:5800
load:0x40078000,len:7924
load:0x40080000,len:5916
entry 0x40080314
I (29) boot: ESP-IDF 3.30103.190221 2nd stage bootloader
I (29) boot: compile time 16:42:04
I (29) boot: Enabling RNG early entropy source...
I (34) boot: SPI Speed : 40MHz
I (38) boot: SPI Mode : DIO
I (42) boot: SPI Flash Size : 4MB
I (46) boot: Partition Table:
I (50) boot: ## Label Usage Type ST Offset Length
I (57) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (64) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (72) boot: 2 factory factory app 00 00 00010000 00100000
I (79) boot: End of partition table
I (84) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x1a4cc (107 724) map
I (130) esp_image: segment 1: paddr=0x0002a4f4 vaddr=0x3ffc0000 size=0x02edc ( 1 1996) load
I (135) esp_image: segment 2: paddr=0x0002d3d8 vaddr=0x40080000 size=0x00400 ( 1024) load
I (137) esp_image: segment 3: paddr=0x0002d7e0 vaddr=0x40080400 size=0x02830 ( 1 0288) load
I (150) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x7e164 (51 6452) map
I (333) esp_image: segment 5: paddr=0x000ae184 vaddr=0x40082c30 size=0x0e2f4 ( 5 8100) load
I (366) boot: Loaded app from partition at offset 0x10000
I (366) boot: Disabling RNG early entropy source...
I (367) cpu_start: Pro cpu up.
I (370) cpu_start: Starting app cpu, entry point is 0x40081a98
I (0) cpu_start: App cpu up.
I (381) heap_init: Initializing. RAM available for dynamic allocation:
I (388) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (394) heap_init: At 3FFC9288 len 00016D78 (91 KiB): DRAM
I (400) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (406) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (413) heap_init: At 40090F24 len 0000F0DC (60 KiB): IRAM
I (419) cpu_start: Pro cpu start user code
I (101) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (103) MQTT_EXAMPLE: [APP] Startup..
I (103) MQTT_EXAMPLE: [APP] Free memory: 201440 bytes
I (103) MQTT_EXAMPLE: [APP] IDF version: 3.30103.190221
I (153) gpio: GPIO[12]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo wn: 0| Intr:0
I (153) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo wn: 0| Intr:0
I (163) gpio: GPIO[18]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo wn: 0| Intr:0
I (173) gpio: GPIO[21]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo wn: 0| Intr:0
I (183) gpio: GPIO[23]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldo wn: 0| Intr:0
I (193) wifi: wifi driver task: 3ffd23cc, prio:23, stack:3584, core=0
I (193) wifi: wifi firmware version: 71d6725
I (203) wifi: config NVS flash: enabled
I (203) wifi: config nano formating: disabled
I (203) system_api: Base MAC address is not set, read default base MAC address f rom BLK0 of EFUSE
I (213) system_api: Base MAC address is not set, read default base MAC address f rom BLK0 of EFUSE
I (243) wifi: Init dynamic tx buffer num: 32
I (243) wifi: Init data frame dynamic rx buffer num: 32
I (243) wifi: Init management frame dynamic rx buffer num: 32
I (243) wifi: Init static rx buffer size: 1600
I (243) wifi: Init static rx buffer num: 10
I (253) wifi: Init dynamic rx buffer num: 32
I (253) MQTT_EXAMPLE: start the WIFI SSID:[Gothic]
I (323) phy: phy_version: 4008, c9ae59f, Jan 25 2019, 16:54:06, 0, 0
I (333) wifi: mode : sta (30:ae:a4:0b:07:f0)
I (333) MQTT_EXAMPLE: Waiting for wifi
I (453) wifi: n:1 1, o:1 0, ap:255 255, sta:1 1, prof:1
I (1293) wifi: state: init -> auth (b0)
I (1293) wifi: state: auth -> assoc (0)
I (1303) wifi: state: assoc -> run (10)
I (1313) wifi: connected with Gothic, channel 1
I (1313) wifi: pm start, type: 1
I (2193) event: sta ip: 192.168.69.103, mask: 255.255.255.0, gw: 192.168.69.69
I (2193) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (2203) MQTT_CLIENT: Sending MQTT CONNECT message, type: 1, id: 0000
I (2243) MQTT_EXAMPLE: MQTT_EVENT_CONNECTED
I (2243) MQTT_EXAMPLE: sent subscribe successful, msg_id=13306
I (2243) MQTT_EXAMPLE: sent subscribe successful, msg_id=32539
I (2253) MQTT_EXAMPLE: sent subscribe successful, msg_id=15354
I (2263) MQTT_EXAMPLE: MQTT_EVENT_SUBSCRIBED, msg_id=13306
I (2263) MQTT_EXAMPLE: sent publish successful, msg_id=19467
I (2273) MQTT_EXAMPLE: MQTT_EVENT_SUBSCRIBED, msg_id=32539
I (2273) MQTT_EXAMPLE: sent publish successful, msg_id=30592
I (2313) MQTT_EXAMPLE: MQTT_EVENT_PUBLISHED, msg_id=19467
I (2453) MQTT_EXAMPLE: MQTT_EVENT_PUBLISHED, msg_id=30592
I (25433) MQTT_CLIENT: deliver_publish, message_length_read=18, message_length=18
I (25433) MQTT_EXAMPLE: MQTT_EVENT_DATA
TOPIC=todev/flags
DATA=1
Guru Meditation Error: Core 0 panic'ed (LoadStoreAlignment). Exception was unhandled.
Core 0 register dump:
PC : 0x4008cfc9 PS : 0x00060c33 A0 : 0x8008bf8e A1 : 0x3ffdad40
A2 : 0x24a8b351 A3 : 0x00000000 A4 : 0x000005a1 A5 : 0x3f4124c8
A6 : 0x3ffc1480 A7 : 0x00060023 A8 : 0x0000abab A9 : 0xb33fffff
A10 : 0x0000cdcd A11 : 0x00060c20 A12 : 0x00060c20 A13 : 0x00000001
A14 : 0x0000cdcd A15 : 0x00000000 SAR : 0x00000000 EXCCAUSE: 0x00000009
EXCVADDR: 0x24a8b351 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
Backtrace: 0x4008cfc9:0x3ffdad40 0x4008bf8b:0x3ffdad60 0x400d2470:0x3ffdada0
Rebooting...
At first I've got the impression that I need some mutexes/semaphores, to work with shared resources (PID coeffs, reference value), but even after the mutexes, I get the same value.
I've attached my project where the problematic part is in the mqtt_event_handler() and/or in the timer_evt_example_task() - in the main.c (I think).
By the way, I'm using VisualStudio Code with PlatformIO and esp-idf
Any suggestions, ideas would be greatly appreciated.