FreeRTOS tasks are not context switching

I use the FreeRTOS port for the PIC32 microcontroller on the PIC32MX starter kit. Just played with tasks, but tasks were not context switching. Here are my basic configuration settings:

#define configMAX_PRIORITIES    ( ( unsigned portBASE_TYPE ) 5 )
#define configKERNEL_INTERRUPT_PRIORITY         0x01
#define configMAX_SYSCALL_INTERRUPT_PRIORITY    0x03
#define configTICK_RATE_HZ              ( ( portTickType ) 100 )

Now I have two tasks that are flashing with two LEDs. Both have priority 4 (highest). During normal operation, the LEDs should flash alternately for every 100 ticks. But this does not happen. The second LED flashes for 100 ticks, and control passes to the general exception handler. Why is this happening? There seems to be no planning at all.

+3
source share
5 answers

FreeRTOS - , , , . , , . .

, - (, ), .

, , , , - . , .

+6

, , "" . , , #pragma, PIC32.., "".

№1 : . , .

, " ", MPLAB void vPortIncrementTick( void ) ( 177 FreeRTOS\Source\portable\MPLAB\PIC32MX\port.c) . , .

+5

? - ( )?

, . , A , A , A , B . , , (, , ).

, , :

for (;;)
{
  led(on); sleep(delay);
  led(off); sleep(delay);
}

... , . , :

for (;;)
{
  led(on);
  led(off);
}

( , , , , , - , .)

+4

, ?

- :

xTaskCreate( yourFirstTask, "firstTask", STACK_SIZE, NULL, TASK_PRIORITY, NULL );
xTaskCreate( yourSecondTask, "secondTask", STACK_SIZE, NULL, TASK_PRIORITY, NULL );
vTaskStartScheduler();

, , , .

+4

, FreeRTOS/Demo/Common/Minimal/flash.c. , , PIC32 ( Microchip Explorer16).

In its simplest form, a task that simply switches and the LED every 500 ms will look like this:

/* Standard task prototype, the parameter is not used in this case. */    
void vADummyTask( void *pvParameters )
{
const portTickType xDelayTime = 500 / portTICK_RATE_MS;

    for( ;; )
    {
        ToggleLED();
        vTaskDelay( xDelayTime );
    }        
}
+3
source

Source: https://habr.com/ru/post/1795228/


All Articles