The way it is, it won't run properly. It throws an exception right after Starting scheduler on APP CPU.
Funny thing is, if I add an infinite loop or vTaskDelete(NULL); in app_main, no exception is thrown.
Could someone help me understand the issue?
Thank you
- #include <stdio.h>
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "freertos/queue.h"
- #include "driver/gpio.h"
- #define PIN_SWITCH 15
- xQueueHandle interputQueue;
- static void IRAM_ATTR gpio_isr_handler(void *args)
- {
- int pinNumber = (int)args;
- xQueueSendFromISR(interputQueue, &pinNumber, NULL);
- }
- void buttonPushedTask(void *params)
- {
- int pinNumber, count = 0;
- while (true)
- {
- if (xQueueReceive(interputQueue, &pinNumber, portMAX_DELAY))
- {
- printf("GPIO %d was pressed %d times. The state is %d\n", pinNumber, count++, gpio_get_level(PIN_SWITCH));
- }
- }
- }
- void app_main()
- {
- gpio_pad_select_gpio(PIN_SWITCH);
- gpio_set_direction(PIN_SWITCH, GPIO_MODE_INPUT);
- gpio_pulldown_en(PIN_SWITCH);
- gpio_pullup_dis(PIN_SWITCH);
- gpio_set_intr_type(PIN_SWITCH, GPIO_INTR_POSEDGE);
- interputQueue = xQueueCreate(10, sizeof(int));
- xTaskCreate(buttonPushedTask, "buttonPushedTask", 2048, NULL, 1, NULL);
- gpio_install_isr_service(0);
- gpio_isr_handler_add(PIN_SWITCH, gpio_isr_handler, (void *)PIN_SWITCH);
- // vTaskDelete(NULL); <= If I add this, no exception is thrown
- }
Code: Select all
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:0x3fff0030,len:4
load:0x3fff0034,len:7016
load:0x40078000,len:13212
load:0x40080400,len:4568
0x40080400: _init at ??:?
entry 0x400806f4
I (29) boot: ESP-IDF v4.2-dirty 2nd stage bootloader
I (29) boot: compile time 21:13:37
I (29) boot: chip revision: 1
I (32) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot.esp32: SPI Speed : 40MHz
I (44) boot.esp32: SPI Mode : DIO
I (49) boot.esp32: SPI Flash Size : 2MB
I (53) boot: Enabling RNG early entropy source...
I (59) boot: Partition Table:
I (62) boot: ## Label Usage Type ST Offset Length
I (69) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (77) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (84) boot: 2 factory factory app 00 00 00010000 00100000
I (92) boot: End of partition table
I (96) boot_comm: chip revision: 1, min. application chip revision: 0
I (103) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x064cc ( 25804) map
I (122) esp_image: segment 1: paddr=0x000164f4 vaddr=0x3ffb0000 size=0x0206c ( 8300) load
I (126) esp_image: segment 2: paddr=0x00018568 vaddr=0x40080000 size=0x00x40080000: _WindowOverflow4 at C:/esp/esp-idf/components/freertos/xtensa/xtensa_vectors.S:1730
I (130) esp_image: segment 3: paddr=0x00018974 vaddr=0x40080404 size=0x076a4 ( 30372) load
I (152) esp_image: segment 4: paddr=0x00020020 vaddr=0x400d0020 size=0x134e0 ( 79072) map
0x400d0020: _stext at ??:?
I (183) esp_image: segment 5: paddr=0x00033508 vaddr=0x40087aa8 size=0x02520 ( 9504) load
0x40087aa8: esp_log_write at C:/esp/esp-idf/components/log/log.c:196
I (193) boot: Loaded app from partition at offset 0x10000
I (193) boot: Disabling RNG early entropy source...
I (194) cpu_start: Pro cpu up.
I (198) cpu_start: Application information:
I (203) cpu_start: Project name: blink
I (208) cpu_start: App version: 1
I (212) cpu_start: Compile time: Apr 18 2021 21:12:57
I (218) cpu_start: ELF file SHA256: 84c3f343b23feb95...
I (224) cpu_start: ESP-IDF: v4.2-dirty
I (229) cpu_start: Starting app cpu, entry point is 0x400815c8
0x400815c8: call_start_cpu1 at C:/esp/esp-idf/components/esp32/cpu_start.c:289
I (0) cpu_start: App cpu up.
I (240) heap_init: Initializing. RAM available for dynamic allocation:
I (247) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (253) heap_init: At 3FFB28A0 len 0002D760 (181 KiB): DRAM
I (259) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (265) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (272) heap_init: At 40089FC8 len 00016038 (88 KiB): IRAM
I (278) cpu_start: Pro cpu start user code
I (296) spi_flash: detected chip: generic
I (297) spi_flash: flash io: dio
W (297) spi_flash: Detected size(4096k) larger than the size in the binary image header(2048k). Using the size in the binary image header.
I (307) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
Guru Meditation Error: Core 0 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x400d189c: e5b7f665 00000131 0c004136
0x400d189c: main_task at C:/esp/esp-idf/components/esp32/cpu_start.c:594 (discriminator 2)
Core 0 register dump:
PC : 0x400d18a2 PS : 0x00060030 A0 : 0x800846b0 A1 : 0x3ffb4710
0x400d18a2: main_task at cpu_start.c:?
A2 : 0x00000000 A3 : 0x00000000 A4 : 0x00060023 A5 : 0x3ffb22c8
A6 : 0x3ffb47c8 A7 : 0x00000000 A8 : 0x800d18a2 A9 : 0x3ffb46e0
A10 : 0x3ff48000 A11 : 0x00000001 A12 : 0x00000001 A13 : 0x00060023
A14 : 0x00000001 A15 : 0x00060023 SAR : 0x00000011 EXCCAUSE: 0x00000000
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff
Backtrace:0x400d189f:0x3ffb4710 0x400846ad:0x3ffb4740
0x400d189f: main_task at C:/esp/esp-idf/components/esp32/cpu_start.c:602 (discriminator 2)
0x400846ad: vPortTaskWrapper at C:/esp/esp-idf/components/freertos/xtensa/port.c:143
ELF file SHA256: 84c3f343b23feb95
Rebooting...