# stm32H743IIT6 freeRTOS stop after one time defaultTask ran

**URL:** <https://forums.freertos.org/t/stm32h743iit6-freertos-stop-after-one-time-defaulttask-ran/18940>\
**Category:** ARM\
**Tags:** debug\
**Created:** [January 15, 2024, 3:16am UTC](https://forums.freertos.org/t/stm32h743iit6-freertos-stop-after-one-time-defaulttask-ran/18940 "2024-01-15T03:16:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![HosseinSadat](https://avatars.discourse-cdn.com/v4/letter/h/a9a28c/32.png) [@HosseinSadat](https://forums.freertos.org/u/HosseinSadat)\
**Post date:** [January 15, 2024, 3:16am UTC](https://forums.freertos.org/t/stm32h743iit6-freertos-stop-after-one-time-defaulttask-ran/18940/1 "2024-01-15T03:16:16Z")

</div>

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:

```auto
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](https://d2v6vdsk2p900z.cloudfront.net/original/2X/0/044614eb8687c85c6e57c018a66b11a0554541cb.png)

---

<div class="post-metadata">

**Author:** ![richard-damon](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/richard-damon/32/38_2.png) [@richard-damon](https://forums.freertos.org/u/richard-damon)\
**Post date:** [January 15, 2024, 3:50am UTC](https://forums.freertos.org/t/stm32h743iit6-freertos-stop-after-one-time-defaulttask-ran/18940/2 "2024-01-15T03:50:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hs2](https://avatars.discourse-cdn.com/v4/letter/h/a4c791/32.png) [@hs2](https://forums.freertos.org/u/hs2)\
**Post date:** [January 15, 2024, 5:50am UTC](https://forums.freertos.org/t/stm32h743iit6-freertos-stop-after-one-time-defaulttask-ran/18940/3 "2024-01-15T05:50:38Z")

</div>

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.
