FreeRTOS Task Switch Example

This example demonstrates task switching and inter-task communication using FreeRTOS. Two tasks, “Main” and “Pong”, interact using semaphores and software interrupts to illustrate context switching and synchronization in a real-time operating system.

This example operates as follows:

  1. The application initializes two tasks:

    • Main Task (higher priority)

    • Pong Task (lower priority)

  2. The Main Task triggers a software interrupt, which signals the Pong Task via a semaphore.

  3. The Pong Task, upon receiving the semaphore, triggers its own interrupt to signal back to the Main Task.

  4. This ping-pong process repeats for a fixed number of iterations.

  5. The example logs progress and indicates success or failure via console output.

Key features demonstrated:

  • FreeRTOS static task and semaphore creation

  • Task synchronization using binary semaphores

  • Software interrupt registration, triggering, and handling

  • Context switching between tasks of different priorities

External Connections

None