Use the uxTaskGetStackHighWaterMark() function to query the stack status

This commit is contained in:
aixiao 2024-04-14 19:09:27 +08:00
parent 60dfae03c2
commit 145e6845a0

View File

@ -42,6 +42,10 @@ void Read_Onboard_Temperature(void *pvParameters)
adc_set_temp_sensor_enabled(true); adc_set_temp_sensor_enabled(true);
adc_select_input(4); // Input 4 is the onboard temperature sensor. adc_select_input(4); // Input 4 is the onboard temperature sensor.
UBaseType_t uxHighWaterMark;
uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );
printf("%ld\n", uxHighWaterMark);
while (1) { while (1) {
const float conversionFactor = 3.3f / (1 << 12); const float conversionFactor = 3.3f / (1 << 12);
@ -50,6 +54,9 @@ void Read_Onboard_Temperature(void *pvParameters)
printf("Onboard temperature %.02f°C %.02f°F\n", tempC, (tempC * 9 / 5 + 32)); printf("Onboard temperature %.02f°C %.02f°F\n", tempC, (tempC * 9 / 5 + 32));
uxHighWaterMark = uxTaskGetStackHighWaterMark( NULL );
printf("%ld\n", uxHighWaterMark);
vTaskDelay(pdMS_TO_TICKS(3000)); // 非阻塞延时 vTaskDelay(pdMS_TO_TICKS(3000)); // 非阻塞延时
} }
} }
@ -73,7 +80,7 @@ int main(void)
// CPU温度 // CPU温度
xReturned = xTaskCreate(Read_Onboard_Temperature, "Temperature task", 512, NULL, tskIDLE_PRIORITY, &Read_Onboard_Temperature_xHandle); xReturned = xTaskCreate(Read_Onboard_Temperature, "Temperature task", 512, NULL, tskIDLE_PRIORITY, &Read_Onboard_Temperature_xHandle);
/*
// IM1253B 电压、功率模块 // IM1253B 电压、功率模块
xReturned = xTaskCreate(IM1253B, "IM1253B task", 1024, NULL, tskIDLE_PRIORITY, &IM1253B_xHandle); xReturned = xTaskCreate(IM1253B, "IM1253B task", 1024, NULL, tskIDLE_PRIORITY, &IM1253B_xHandle);
@ -85,7 +92,7 @@ int main(void)
// HC-04 蓝牙模块 // HC-04 蓝牙模块
xReturned = xTaskCreate(HC_04, "HC_04 task", 512, NULL, tskIDLE_PRIORITY, &HC_04_xHandle); xReturned = xTaskCreate(HC_04, "HC_04 task", 512, NULL, tskIDLE_PRIORITY, &HC_04_xHandle);
*/
vTaskStartScheduler(); vTaskStartScheduler();
return 0; return 0;