# \[freeRTOS\] Second Task creation issue and control stuck everytime in port.c file only

**URL:** <https://forums.freertos.org/t/freertos-second-task-creation-issue-and-control-stuck-everytime-in-port-c-file-only/15784>\
**Category:** Libraries\
**Tags:** debug\
**Created:** [September 8, 2022, 7:17am UTC](https://forums.freertos.org/t/freertos-second-task-creation-issue-and-control-stuck-everytime-in-port-c-file-only/15784 "2022-09-08T07:17:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanaiyasharma1992](https://avatars.discourse-cdn.com/v4/letter/k/edb3f5/32.png) [@kanaiyasharma1992](https://forums.freertos.org/u/kanaiyasharma1992)\
**Post date:** [September 8, 2022, 7:17am UTC](https://forums.freertos.org/t/freertos-second-task-creation-issue-and-control-stuck-everytime-in-port-c-file-only/15784/1 "2022-09-08T07:17:21Z")

</div>

Hi Support Team,

**Project Name:** freeRTOS integration with the WiFi module’s code using the STM32H743ZI

I am trying to integrate the freeRTOS library with one of the WiFi modules by using the host MCU STM32H743ZI. I am using the STM32cube IDE.

I generated the freeRTOS middleware and integrated the code successfully. I have created the 2 tasks like Application task and the Driver task. I gave a higher priority to the Driver task as compared to the Wireless task.

This is the configuration that I am using:  
#define RSI\_APPLICATION\_TASK\_PRIORITY 1 // Wlan task priority  
#define RSI\_DRIVER\_TASK\_PRIORITY 2 // Wireless driver task priority

#define RSI\_APPLICATION\_TASK\_STACK\_SIZE (512 \* 2) // Wlan task stack size  
#define RSI\_DRIVER\_TASK\_STACK\_SIZE (512 \* 2) // Wireless driver task stack size

I am able to create the first task (RSI\_APPLICATION\_TASK\_PRIORITY) and after that, I called the OS Task scheduler. later I am trying to create the second task (RSI\_DRIVER\_TASK\_PRIORITY), and there my control goes into an infinite loop. After suspending the debug mode I saw my control always goes into the below (if condition) part which is available in the port.c file:  
if( ulCurrentInterrupt \>= portFIRST\_USER\_INTERRUPT\_NUMBER )

For reference, I have attached here the port.c file and freeRTOS .ioc file images.

 ![port_c_file](https://d2v6vdsk2p900z.cloudfront.net/original/2X/2/288fb9eb651f45a35786f8c1cf92ad54cada6d87.png)

Please help me to resolve this issue.

Thanks in advance.

Regards,  
Kaniaya Sharma

---

<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:** [September 8, 2022, 8:29am UTC](https://forums.freertos.org/t/freertos-second-task-creation-issue-and-control-stuck-everytime-in-port-c-file-only/15784/2 "2022-09-08T08:29:07Z")

</div>

Probably the HW interrupt priority set in NVIC is incorrect.  
Have a look at this related documentation:

> **[RTOS for ARM Cortex-M](https://www.freertos.org/RTOS-Cortex-M3-M4.html)**
>
> Setting RTOS interrupt priorities on a ARM Cortex-M microcontroller

and this very good forum posts:

> [@What is config KERNEL INTERRUPT PRIORITY?](https://forums.freertos.org/t/what-is-config-kernel-interrupt-priority/11501/8):
>
> Why is it that “Interrupts that call API functions must also execute at this priority”? Is there an example? What is the treatment different between interrupts which call, and don’t call, API functions? For the discussion below, lets make the following assumptions: Numerically higher priority interrupts have logically higher priority (i.e. priority 2 interrupt can preempt priority 1 interrupt handler). The port implements configKERNEL\_INTERRUPT\_PRIORITY and configMAX\_SYSCALL\_INTERRUPT\_PRIO…

> [@Understanding priority levels of ISR and FreeRTOS APIs](https://forums.freertos.org/t/understanding-priority-levels-of-isr-and-freertos-apis/10453/16):
>
> A pictorial representation, if that helps: Logical Numerical Priorities Priorities +--------+ +-------+ ^ | | | | | | | | | | | | | | | Not masked by FreeRTOS kernel | Higher | | Lower | | ( FreeRTOS APIs can not be | | | | | called from these ISRs. ) …

---

<div class="post-metadata">

**Author:** ![kanaiyasharma1992](https://avatars.discourse-cdn.com/v4/letter/k/edb3f5/32.png) [@kanaiyasharma1992](https://forums.freertos.org/u/kanaiyasharma1992)\
**Post date:** [September 9, 2022, 8:36am UTC](https://forums.freertos.org/t/freertos-second-task-creation-issue-and-control-stuck-everytime-in-port-c-file-only/15784/3 "2022-09-09T08:36:42Z")

</div>

Hi Hartmut,

Thanks for your reply.  
I did the mistake in the API (HAL\_NVIC\_SetPriority(EXTI3\_IRQn, **GPIO\_PIN\_3** , 0);), I configured the interrupt pin wrongly. Now it’s working for me.

Regards,  
Kanaiya Sharma
