After first execution control goes to task 2 but i want him to go to task1 what i suppose to do here?

In my case i have two tasks. First is to print menu on the UART (with default baud rate) and the second task will take input from the user and will execute related function eg. task 1 shows menu (so user can see options and enter his choise) then let say, in task 2 user entered ā€œsā€ then uart setting function will run and user can edit serial port configuration.

So, after changing the UART terminal setting like setting buad rate, parity bit etc control will goes to prvSetupHardware() and the edited settings will get applied.

But, after this the control is directly going to the task 2 which is for to get input from user and task 1 is not running which is supposed to be run.

So what can i do so that after execution of the function prvSetupHardware()
control will go to task1 then task2.

FreeRTOS schedules tasks on highest priority task runs first. So one option is to make task 1 have a higher priority than task 2.

One question to thing about, do you need two tasks. t sounds like you are alway going to have sort of a loop, task 1 run, then task 2, and then maybe back to task 1, then back to task 2. If they will never be running at the same time, do they need to be separate tasks?

1 Like

Iā€˜d also bundle the input and output functionality in 1 task because if I got it right they are executed sequentially and deal with the same UART peripheral, which could simplify the UART driver implementation, too.

1 Like

Thanks a lot @richard-damon actually you are right instead of using two I will go for one only.

Thanks for sharing @hs2. Actually my TASK is to take input from user (eg. baud rate,no of parity bits and stop bits etc). So according to the entered configuration by user (during runtime) the UART configuration will get change. After this user need to open the other terminal on which the menu will be shown again to him. Until now i was using two tasks but now i will go for only one task.