[已解决] 使用FreeRTOS队列时发生PRO CPU has been reset by WDT.

panpengxian
Posts: 2
Joined: Tue Aug 03, 2021 3:36 pm

[已解决] 使用FreeRTOS队列时发生PRO CPU has been reset by WDT.

Postby panpengxian » Tue Aug 03, 2021 3:44 pm

以下是我的代码,我只是想试一下FreeRTOS的QUeue能不能用,主要就是让一个任务累加发送整数,让另一个任务打印整数;
但是我发现累加到3662之后,CPU就会重启,然后重新累加,报错信息如下,这段程序我是按照FreeRTOS的官方手册写的,不知道有什么错误?

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:6972
ho 0 tail 12 room 4
load:0x40078000,len:14292
load:0x40080400,len:3688
0x40080400: _init at ??:?

entry 0x40080678
I (57) boot: ESP-IDF v4.3-dirty 2nd stage bootloader
I (58) boot: compile time 23:09:01
I (58) boot: chip revision: 1
I (61) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (68) boot.esp32: SPI Speed : 40MHz
I (73) boot.esp32: SPI Mode : DIO
I (78) boot.esp32: SPI Flash Size : 4MB
W (82) boot.esp32: PRO CPU has been reset by WDT.
W (87) boot.esp32: WDT reset info: PRO CPU PC=0x4008568e
0x4008568e: _xt_context_save at /Users/guosa/esp/esp-idf/components/freertos/port/xtensa/xtensa_context.S:149

W (93) boot.esp32: WDT reset info: APP CPU PC=0x4008520e
0x4008520e: panic_handler at /Users/guosa/esp/esp-idf/components/esp_system/port/panic_handler.c:146 (discriminator 1)
  1. void send_string(void *pvParameters){
  2.     BaseType_t xStatus;
  3.     int a = (int)pvParameters;
  4.     // char output_buffer[2048] ="Hello World!";
  5.     for(;;)
  6.     {
  7.         a += 1;
  8.         xStatus = xQueueSendToBack(xQueue, &a, 0);
  9.         if (xStatus != pdPASS)
  10.         {
  11.             printf("Cound not send to the queue.\n");
  12.         }
  13.    
  14.     }
  15. }
  16.  
  17. void print(void *pvParameters){
  18.     int a;
  19.     BaseType_t xStatus;
  20.     const TickType_t xTicksToWait = pdMS_TO_TICKS(100);
  21.     for(;;)
  22.     {
  23.         // if( uxQueueMessagesWaiting( xQueue ) != 0)
  24.         // {
  25.         //     printf("The queue should have been empty!\n");
  26.         // }
  27.         xStatus = xQueueReceive( xQueue, &a, xTicksToWait);
  28.         if ( xStatus == pdPASS)
  29.         {
  30.             printf("output is %d\n", a);
  31.         }
  32.         else
  33.         {
  34.             printf("Could not reveive from the queue.\n");
  35.         }
  36.        
  37.     }
  38. }
  39.  
  40. void app_main(void)
  41. {  
  42.     xQueue = xQueueCreate(5,sizeof(int));
  43.     // http_connect();
  44.     if (xQueue!=NULL)
  45.     {
  46.         xTaskCreate(send_string, "send_string", 10000, (void*)1, 5, NULL);
  47.         xTaskCreate(print, "print", 10000, NULL, 6, NULL);
  48.         vTaskStartScheduler();
  49.     }
  50.  
  51. }

ESP_Sprite
Posts: 9724
Joined: Thu Nov 26, 2015 4:08 am

Re: 使用FreeRTOS队列时发生PRO CPU has been reset by WDT.

Postby ESP_Sprite » Wed Aug 04, 2021 1:44 am

你不需要做 vTaskStartScheduler

panpengxian
Posts: 2
Joined: Tue Aug 03, 2021 3:36 pm

Re: 使用FreeRTOS队列时发生PRO CPU has been reset by WDT.

Postby panpengxian » Wed Aug 04, 2021 1:58 pm

ESP_Sprite wrote:
Wed Aug 04, 2021 1:44 am
你不需要做 vTaskStartScheduler
原来是这样,可以连续运行了,谢谢

Who is online

Users browsing this forum: No registered users and 135 guests