I have two tasks, T1 and T2. I want to switch between these two by invoking an ISR, yet, T1 and T2 both have their private vTaskDelay. How to let them run smoother when delay is in the code?
void T1(void){
while(1){
if (tsk == 1) {
/// doSth
vTaskDelay(2000) // 2seconds
// doSth
}
}
}
void T2(void){
while(1){
if (tsk == 2) {
/// doSth
vTaskDelay(1000) // 1seconds
// doSth
}
}
}
void ISR(){
if (READGPIO){
// change tsk between 1 and 2
}
}
I tried spliting vTaskDelay into small pieces like this
for (int i = 0; i < 200; i++) {
vTaskDelay(10);
if (tsk == 1) break;;
}
however, it doesnot help with the smoothness i except
It would help if you learned a bit more about inter-task communication primitives before starting programming using RTOS.
Use for example task notifications and give the notification to the particular task from the ISR.