This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to create two task with different task priority?

SDK version: 14.2.0



I use "ble_app_hrs_freertos" as code base and modify it to create a "ble_app_template_freertos" project.

"softdevice_task" is already in this project (uxPriority = 2).

I can use "xTaskCreate" to create a new task "task1" and the uxPriority is 1, and work normally.

And I modify "softdevice_taskuxPriority to 5, and "task1" uxPriority is 1 it works normally too.

But when I add a new task "task2" and the uxPriority set to 2, the system not work.

And I found when this project only have "softdevice_task"(uxPriority = 5) and "task1"(uxPriority = 2), it doesn't work too.

How to solve this issue?

The code config below doesn't work.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int main(void)
{
bool erase_bonds;
clock_init();
if (pdPASS != xTaskCreate(task1_thread, "TASK1", 128, p_context, 1, &m_task1_thread))
{
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
if (pdPASS != xTaskCreate(task2_thread, "TASK2", 128, p_context, 2, &m_task2_thread))
{
APP_ERROR_HANDLER(NRF_ERROR_NO_MEM);
}
// Activate deep sleep mode.
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
// Configure and initialize the BLE stack.
ble_stack_init();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX