Hey i have a question, im not totally sure why this is going to happen in this way.
I have created two task, both of them turn a led on and off.
The scenario is that task1 has the lowest priority and toggels the led 3 times and then gives a semaphore, instantly the task1 is interrupted by task2, because task2 has the higher priority. Futhermore if task2 gets the semaphore the task should toggel the led on time and then go again into blocked mode because he cant take the semaphore again.
Example one with delay loops;
~~~~
void vTask1( void * pvParameters ){
int i=0;
for(;;){
for(i=0;i<3;i++){
LED_Task1_on();
delay1s();
LED_Task1_off();
delay1s();
}
xSemaphoreGive( xSemaphore );
}
}
void vTask2( void * pvParameters ){
for(;;){
if( xSemaphoreTake( xSemaphore, portMAX_DELAY ) == pdTRUE ){
LED_Task2_on();
delay1s();
LED_Task2_off();
delay1s();
}
}
}
~~~~
Example2, with tickrate 1Mhz
~~~~
void vTask1( void * pvParameters ){
int i=0;
for(;;){
for(i=0;i<3;i++){
LED_Task1_on();
delay1s();
LED_Task1_off();
delay1s();
}
xSemaphoreGive( xSemaphore );
}
}
void vTask2( void * pvParameters ){
for(;;){
if( xSemaphoreTake( xSemaphore, portMAX_DELAY ) == pdTRUE ){
LED_Task2_on();
vTaskDelay(1000);
LED_Task2_off();
vTaskDelay(1000);
}
}
}
~~~~
If i use example one everthing is fine, but when is use example two, task1 is going to execute only once and the the led of task2 is blinking forever.
For my understanding it shouldn’t change a thing if i use vTaskDelay or a loop delay(task2), right? Or am i totally wrong?
kind regard phil