CodeRigor

FREE COURSE / REAL PRACTICE

FreeRTOS & CMSIS (C++)

Study FreeRTOS task and queue behavior, priority inheritance, ISR handoff, timers and CMSIS contracts through the supplied exercises.

Free lessons & exercises7 authored lessons3 units

What you’ll work toward

Reason about scheduling, synchronization and interrupt boundaries while identifying the hardware-specific work that remains.

Read an explanation, inspect the diagrams and work through the available checks, debugging exercises and builds. Feedback and prerequisite links guide the next step.

Before you start

The entry lesson has no earlier CodeRigor skill prerequisite. Start there and follow the sequence.

Individual lessons can add prerequisites. The course map shows your actual readiness.

A look inside the first lesson

Tasks, scheduling and queues (FreeRTOS)

C++
#include "FreeRTOS.h"
#include "task.h"
#include <cstdio>
#include <cstdlib>

static void blinker(void* arg) {
    const char* name = static_cast<const char*>(arg);
    for (int i = 0; i < 3; ++i) {
        std::printf("tick %3lu: %s\n", (unsigned long)xTaskGetTickCount(), name);
        vTaskDelay(pdMS_TO_TICKS(name[0] == 'f' ? 10 : 25));  // Blocked: costs no CPU
    }
    if (name[0] == 's') std::exit(0);  // end the program (semihosting)
    vTaskDelete(nullptr);              // a task function must never return
}

int main() {
    xTaskCreate(blinker, "fast", 512, (void*)"fast", 1, nullptr);  // 512 words of stack
    xTaskCreate(blinker, "slow", 512, (void*)"slow", 1, nullptr);
    vTaskStartScheduler();  // never returns while the scheduler runs
}

Your course outline

Follow the lessons in curriculum order. Open a unit to preview the ideas you’ll work with.

UNIT 014 lessons RTOS on the Cortex-M4 (FreeRTOS)
  1. LESSON 01.01

    Tasks, scheduling and queues (FreeRTOS)

    FreeRTOS on a Cortex-M4: task states, preemptive priority scheduling and time slicing, the idle task, vTaskDelay vs xTaskDelayUntil, stack budgets with high-water marks, queues (copy semantics and passing ownership by pointer), timeouts, task notifications, and static vs dynamic allocation.

    Open lesson
  2. LESSON 01.02

    Priority inversion, mutexes and deadlock

    Why a high-priority FreeRTOS task can wait on a medium one: unbounded priority inversion, Mars Pathfinder, binary semaphores vs mutexes, priority inheritance and its limits, priority ceilings, recursive mutexes, deadlock and lock ordering — and a shared-bus guard with a deadline monitor and an ownership trace.

    Open lesson
  3. LESSON 01.03

    From interrupt to task (deferred processing)

    Deferred interrupt processing under FreeRTOS on the Cortex-M4: waking tasks from ISRs with task notifications, queues and stream buffers, portYIELD_FROM_ISR and the latency it saves, ISR priorities versus configMAX_SYSCALL_INTERRUPT_PRIORITY (and the assert you get when it's wrong), what an ISR may call, counting overruns, and stopping an ISR-fed task cleanly.

    Open lesson
  4. LESSON 01.04

    Fault detection and recovery under an RTOS

    Keeping FreeRTOS firmware alive when a task gets stuck: hardware and software watchdogs, heartbeats with deadlines, restarting a task with fresh state, xTaskAbortDelay, timeouts on every wait, stack-overflow checks and configASSERT, fault records that survive a reset, and fail-safe states.

    Open lesson
UNIT 021 lesson RTOS: software timers & event coordination
  1. LESSON 02.01

    Software timers, event flags & daemon lifetime

    Use FreeRTOS software timers and event groups: daemon callbacks, ANY/ALL waits, coalescing, timeout snapshots, static storage and acknowledgement of asynchronous deletion.

    Open lesson
UNIT 032 lessons CMSIS: Cortex-M Core & RTOS2 on FreeRTOS
  1. LESSON 03.01

    CMSIS-Core: device headers, NVIC & intrinsics

    Use Arm CMSIS-Core on the Cortex-M4: device configuration, logical NVIC priorities, nested PRIMASK guards, barriers and saturating intrinsics.

    Open lesson
  2. LESSON 03.02

    CMSIS-RTOS2 on FreeRTOS: threads, queues & API contracts

    Run the CMSIS-RTOS2 API on the real FreeRTOS kernel: byte-sized thread stacks, priorities, copied messages, bounded waits, flags and adapter limits.

    Open lesson