stm32H743IIT6 freeRTOS stop after one time defaultTask ran

Hi stm Community,

I have an issue with freeRTOS when I add DHT22 initial and getdata function to the default task. I tried many options but had no success. I set up freeRTOS v2 in MX and built a second task. add my dht22 library to main.c and initialize it in default task:

void StartDefaultTask(void *argument)
{

/* USER CODE BEGIN 5 */

DWT_Delay_Init();

DHT22_Init(DHT22_GPIO_Port, DHT22_Pin);

/* Infinite loop */

for(;;)

{b++;

DHT22_GetTemp_Humidity(&temperature,&humidity);

HAL_GPIO_TogglePin(LED2_GPIO_Port,LED2_Pin);

osDelay(1000);

}

/* USER CODE END 5 */

}

after I compiled it, I found just one temperature and humidity data and after that MCU not working and LEDs kept ON.

I put global variable b to count how many times the default task ran and it sticks on “1”.

how can I solve this problem?

total heap size: one-time default next time on 65536

task stack size 8192

Screenshot 2024-01-15 062944

The first thing to do is see what the processor is doing at this time.

What task is running, and why it isn’t giving up the processor.

Ensure that the counter b is volatile. Otherwise it might not work as expected at least with an optimized build.
Since you have a debugger attached just put a breakpoint at e.g. DHT22_Init and step through the code to see what’s going on.