esp32-wroom-32e 无限重启
Posted: Tue Jul 11, 2023 6:46 am
我想要通过mlx采集一些数据并在lcd上面显示出来,之后并通过wifi传送到主机上,但是通过队列传送数据就会报错,lcd驱动没有错误,之前成功显示过。有无大佬指定一二,
以下是在monitor中的日志信息
以下是我的主要程序代码,我把后面wifi发送功能注销了,依然会重启
以下是在monitor中的日志信息
Code: Select all
rst:0x8 (TG1WDT_SYS_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:6952
load:0x40078000,len:15500
ho 0 tail 12 room 4
load:0x40080400,len:3844
entry 0x4008064c
0x40080400: _init at ??:?
I (58) boot: ESP-IDF HEAD-HASH-NOTFOUND 2nd stage bootloader
I (58) boot: compile time 12:40:52
I (58) boot: chip revision: v3.0
I (62) boot.esp32: SPI Speed : 40MHz
I (67) boot.esp32: SPI Mode : DIO
I (72) boot.esp32: SPI Flash Size : 16MB
W (76) boot.esp32: PRO CPU has been reset by WDT.
W (82) boot.esp32: WDT reset info: PRO CPU PC=0x4008598e
0x4008598e: _xt_panic at E:/Software/Espressif/frameworks/esp-idf-v5.0.2/components/esp_system/port/arch/xtensa/panic_handler_asm.S:29
W (88) boot.esp32: WDT reset info: APP CPU PC=0x400d1c82
0x400d1c82: panic_handler at E:/Software/Espressif/frameworks/esp-idf-v5.0.2/components/esp_system/port/panic_handler.c:140 (discriminator 1)
I (94) boot: Enabling RNG early entropy source...
I (99) boot: Partition Table:
I (103) boot: ## Label Usage Type ST Offset Length
I (110) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (118) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (125) boot: 2 factory factory app 00 00 00010000 00100000
I (133) boot: End of partition table
I (137) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=0c340h ( 49984) map
I (156) esp_image: segment 1: paddr=0001c368 vaddr=3ffb0000 size=0208ch ( 8332) load
I (158) esp_image: segment 2: paddr=0001e3fc vaddr=40080000 size=01c1ch ( 7196) load
I (164) esp_image: segment 3: paddr=00020020 vaddr=400d0020 size=1e8fch (125180) map
I (197) esp_image: segment 4: paddr=0003e924 vaddr=40081c1c size=0db0ch ( 56076) load
I (219) boot: Loaded app from partition at offset 0x10000
I (219) boot: Disabling RNG early entropy source...
I (230) cpu_start: Pro cpu up.
I (231) cpu_start: Starting app cpu, entry point is 0x40081360
0x40081360: call_start_cpu1 at E:/Software/Espressif/frameworks/esp-idf-v5.0.2/components/esp_system/port/cpu_start.c:141
I (0) cpu_start: App cpu up.
I (247) cpu_start: Pro cpu start user code
I (247) cpu_start: cpu freq: 160000000 Hz
I (247) cpu_start: Application information:
I (252) cpu_start: Project name: main
I (256) cpu_start: App version: 1
I (261) cpu_start: Compile time: Jul 11 2023 12:39:14
I (267) cpu_start: ELF file SHA256: 34dcd2376a882970...
I (273) cpu_start: ESP-IDF: HEAD-HASH-NOTFOUND
I (279) cpu_start: Min chip rev: v0.0
I (284) cpu_start: Max chip rev: v3.99
I (288) cpu_start: Chip rev: v3.0
I (293) heap_init: Initializing. RAM available for dynamic allocation:
I (300) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (306) heap_init: At 3FFB5238 len 0002ADC8 (171 KiB): DRAM
I (313) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (319) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (325) heap_init: At 4008F728 len 000108D8 (66 KiB): IRAM
I (333) spi_flash: detected chip: generic
I (336) spi_flash: flash io: dio
I (341) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (352) MAIN: I2C config OK!
I (352) gpio: GPIO[25]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (362) gpio: GPIO[26]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (372) gpio: GPIO[33]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
ets Jul 29 2019 12:21:46
Code: Select all
void i2c_init(){
// I2C配置,多个mlx90640共用一个
i2c_config_t config;
config.mode = I2C_MODE_MASTER;
config.scl_io_num = 18;
config.scl_pullup_en = GPIO_PULLUP_ENABLE;
config.sda_io_num = 19;
config.sda_pullup_en = GPIO_PULLUP_ENABLE;
config.master.clk_speed = 400000;
config.clk_flags = I2C_SCLK_SRC_FLAG_FOR_NOMAL;
i2c_param_config(I2C_NUM_0, &config);
i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0); //将配置写入寄存器
}
void mlx90640_task(void *mlx90640_config){
mlx90640_t *mlx90640 = (mlx90640_t *) mlx90640_config;
uint8_t slaveAddr = mlx90640->address;
uint8_t index = mlx90640->mlx_index;
uint8_t i2c_num = mlx90640->i2c_num;
uint16_t extraParam[832]={0};
uint16_t Frame[834]={0};
paramsMLX90640 Param={0};
float temperature;
// 利用i2c传数据之前先上锁,用完之后再解锁
if(i2c_num) xSemaphoreTake(i2c_handle1,portMAX_DELAY);
else xSemaphoreTake(i2c_handle0,portMAX_DELAY);
MLX90640_SetRefreshRate(slaveAddr, REFRESH_RATE);//测量速率(0~7对应0.5,1,2,4,8,16,32,64Hz)
MLX90640_DumpEE (slaveAddr, extraParam);
if(i2c_num) xSemaphoreGive(i2c_handle1);
else xSemaphoreGive(i2c_handle0);
MLX90640_ExtractParameters(extraParam, &Param);
while(1){
ESP_LOGI(TAG, "collect data at mlx_%d!",index);
if(i2c_num) xSemaphoreTake(i2c_handle1,portMAX_DELAY);
else xSemaphoreTake(i2c_handle0,portMAX_DELAY);
MLX90640_GetFrameData(slaveAddr, Frame);
if(i2c_num) xSemaphoreGive(i2c_handle1);
else xSemaphoreGive(i2c_handle0);
temperature = MLX90640_GetTa(Frame, &Param) - TA_SHIFT;
MLX90640_CalculateTo(Frame, &Param, EMISSIVITY, temperature, tr_result[index]);
printf("frame data ready at %d!\n",index);
// 等待所有mlx的数据收集完毕
ESP_LOGI(TAG, "wait for all data ready at mlx_%d!",index);
xEventGroupSync(data_flow,1ULL<<index,1ULL<<23,portMAX_DELAY);
}
}
void data_sync_task(){
while(1){
// 等待所有数据采集完毕
xEventGroupWaitBits(data_flow,0xFFFFFF>>(24-MLX_NUM),pdTRUE,pdTRUE,portMAX_DELAY);
ESP_LOGI(TAG, "data ready!");
if (uxQueueSpacesAvailable(lcd_data_queue) > 0) {
if (xQueueSend(lcd_data_queue, &tr_result, portMAX_DELAY) != pdPASS) {
ESP_LOGI(TAG, "send data error!");
}
}
if (uxQueueSpacesAvailable(tcp_data_queue) > 0) {
if (xQueueSend(tcp_data_queue, &tr_result, portMAX_DELAY) != pdPASS) {
ESP_LOGI(TAG, "send data error!");
}
}
// 将数据采集标志位置高
xEventGroupSetBits(data_flow,1ULL<<23);
ESP_LOGI(TAG, "Send data to queue done!");
}
}
void ST7798_task(){
float data[MLX_NUM][768];
while(1){
xQueueReceive(lcd_data_queue,&data,portMAX_DELAY);
for(int i=0;i<MLX_NUM;i++){
lcd_refresh(i,data[i]);
}
}
}
void app_main(void)
{
// 两个信息量初始赋值
i2c_handle0 = xSemaphoreCreateMutex();
i2c_handle1 = xSemaphoreCreateMutex();
xSemaphoreGive( i2c_handle0 );
xSemaphoreGive( i2c_handle1 );
data_flow = xEventGroupCreate();
lcd_data_queue = xQueueCreate(10,MLX_NUM*768*sizeof(float));
tcp_data_queue = xQueueCreate(10,MLX_NUM*768*sizeof(float));
i2c_init();
ESP_LOGI(TAG, "I2C config OK!");
lcd_init();
ESP_LOGI(TAG, "LCD initial OK!");
// nvs_flash_init();
// wifi_init();
mlx90640_t mlx_config;
mlx_config.address = 0x37;
mlx_config.i2c_num = 0;
mlx_config.mlx_index = 0;
xTaskCreate(mlx90640_task,"mlx_task1",1024 * 15,(void *) &mlx_config,1,NULL);
vTaskDelay(100/portTICK_PERIOD_MS);
mlx_config.address = 0x33;
mlx_config.i2c_num = 0;
mlx_config.mlx_index = 1;
xTaskCreate(mlx90640_task,"mlx_task2",1024*15,(void *) &mlx_config,1,NULL);
xTaskCreate(data_sync_task,"dataSync_task",1024*2,NULL,2,NULL);
// xTaskCreate(tcp_task,"tcp_task",1024*10,NULL,3,NULL);
xTaskCreate(ST7798_task,"lcd_task",1024*15,NULL,3,NULL);
while(1)
{
vTaskDelay(10000/portTICK_PERIOD_MS);
char pcWriteBuffer[512]={0};
vTaskList(pcWriteBuffer);
printf("-----------------------------------\n");
printf("name-------state-priority-stack-num\n");
printf("%s\n",pcWriteBuffer);
}
}