Hands-On RTOS with Microcontrollers - Second Edition

Book description

A comprehensive guide designed to provide practical kills and insights to supercharge your embedded engineering journey All formats include a free PDF and an invitation to the Embedded System Professionals community

Key Features

  • Unlock the secrets of RTOS and master them on the highly capable STM32 platform
  • Upgrade your programming skills and elevate your game in building top-notch embedded systems
  • Master the art of RTOS implementation and explore the vast array of possibilities for your embedded systems.

Book Description

Want to stay ahead of the curve with embedded systems development? The updated edition of Hands-On RTOS with Microcontrollers is here and packed with cutting-edge content to up your skills.

This book contains everything you need to know about real-time operating systems, how they work, and why they’re essential for today’s time-critical applications; learn about FreeRTOS and its primary capabilities and APIs.

You’ll find a detailed overview of system-design topics such as memory management, project-design topics (MCU, IDE, and RTOS API), and hands-on system use, as well as the system platform, dev-board with an MCU and debug-probe, and development tools (IDE, build system, source-code debugging).

The new edition includes 10 real-world embedded applications showcasing the latest features of FreeRTOS, teaching you how to implement them in your own projects and exploring how to optimize your code with dynamic analysis.

It also provides example programs on a GitHub repo for you to explore with detailed instructions. You’ll learn how to create and install your own FreeRTOS system on the dev-board, and set up an IDE project with debugging tools. With dozens of reference manuals listed, you’ll never be short on resources for system development.

Stay ahead of the curve — get your second edition of Hands-On RTOS with Microcontrollers today!

What you will learn

  • Understand RTOS, use-cases and decide when to (and not-to) use real-time OS
  • Utilize FreeRTOS scheduler to create, start and monitor task states
  • Improve task signaling and communication using queues, semaphores, and mutexes
  • Streamline task data transfer with queues and notifications
  • Upgrade peripheral communication via UART using drivers and ISRs
  • Enhance interface architecture with a command queue for better system control
  • Maximize FreeRTOS memory management with trade-off insights

Who this book is for

This book is an indispensable guide for systems-programmers, embedded-systems engineers, and software-developers who want to learn about Real-Time Operating Systems (RTOS) and how to use FreeRTOS in their embedded system design. A basic understanding of the C programming language and embedded systems and microcontrollers will be helpful.

Table of contents

  1. Hands-On RTOS with Microcontrollers, Second Edition: Create high-performance, real-time embedded systems using FreeRTOS, STM32 MCUs and SEGGER debug tools
  2. 01 Introducing Real-Time Systems
    1. Join our book community on Discord
    2. Technical requirements
    3. What is real-time anyway?
    4. The ranges of timing requirements
    5. The ways of guaranteeing real-time behavior
    6. Types of real-time systems
    7. Hardware
    8. Bare-metal firmware
    9. RTOS-based firmware
    10. RTOS-based software
    11. Carefully crafted OS software
    12. Defining RTOS
    13. Hard real-time systems
    14. Firm real-time systems
    15. Soft real-time systems
    16. Practical real-time systems
    17. The range of RTOSes
    18. The RTOS used in this book
    19. Deciding when to use an RTOS
    20. Summary
  3. 02 Introducing the Development-Board
    1. Join our book community on Discord
    2. Dev-board overview
    3. Understanding the dev-board’s components
      1. The micro-controller unit (MCU)
      2. The CPU
      3. Other components in the MCU-part
      4. The ST-LINK debug-probe
    4. Understanding the hardware documentation
      1. MCU families
      2. MCU model names
      3. Dev-board families and model-names
    5. Summary
  4. 03 Introducing the Development Tools
    1. Join our book community on Discord
    2. Using the book’s instructions and example-programs
    3. The IDE and the example-programs
      1. Introducing STM32CubeIDE
      2. Installing STM32CubeIDE
      3. Installing the book’s example-programs
      4. Using the Project Explorer
      5. Using the editor
      6. Building a project
    4. The debugging tools: J-Link, Ozone and SystemView
    5. Summary
  5. 04 Understanding Super-Loops
    1. Join our book community on Discord
    2. Introducing super-loops
      1. The basic super-loop
      2. Super-loops in real-time systems
    3. Improving the super-loop with interrupts
      1. Introducing interrupts
      2. Understanding ISRs and jitter
      3. Interrupts and super-loops
    4. Adding a timer to the super-loop
      1. Putting the timed super-loop to sleep
      2. Taking advantage of the timed super-loop
      3. Timing-related performance analysis
    5. Summary
  6. 05 Implementing the Super-Loop
    1. Join our book community on Discord
    2. Super-loop example program
      1. Technical requirements
      2. Super-loop overview
      3. Super-loop initialization
      4. The super-loop
      5. Timing resilience
      6. Testing and debugging
      7. Running the example program
      8. Learning about system APIs and hardware features
    3. How to create the super-loop program
      1. Create the IDE project
      2. Configure the hardware
      3. Create the user-code
      4. Install and configure the debugger software
      5. Build and run the firmware
      6. Using an oscilloscope to measure timing
    4. Summary
  7. 06 Understanding RTOS Tasks
    1. Join our book community on Discord
    2. The FreeRTOS scheduler and tasks: a conceptual view
      1. The need for something more than a super-loop [JY: from 1E Ch2.3.4]
      2. Comparing RTOS tasks to super-loop functions [JY: from 1E Ch2.4]
      3. Changing super-loop functions into RTOS tasks [JY: from 1E Ch2.5]
    3. Choosing FreeRTOS as our RTOS
    4. Hands-on with FreeRTOS’s scheduler and tasks
      1. Understanding and working with the example program
      2. Installing and configuring FreeRTOS
    5. Summary
  8. 07 Running the FreeRTOS Scheduler
    1. Join our book community on Discord
    2. Creating tasks and starting the scheduler
      1. Initializing hardware
      2. Defining task functions
      3. Creating tasks
      4. Checking the return value
      5. Starting the scheduler
    3. Deleting tasks
      1. The task deletes itself
      2. Deleting a task from another task
    4. Trying out the code
      1. Building and running the code
      2. Additional Ozone features
      3. Using SystemView to analyze task execution
    5. Understanding the scheduler
      1. Understanding FreeRTOS task states
      2. The Idle task
      3. How and when the scheduler is run
      4. The scheduler architecture
    6. Task implementation and troubleshooting
      1. Task memory allocation
      2. Optimizing task states
      3. Troubleshooting task startup problems
    7. Summary
  9. 8 Protecting Data and Synchronizing Tasks
    1. Join our book community on Discord
    2. Running the chapter’s example-programs
    3. Semaphores
      1. Understanding semaphores
      2. Using semaphores
    4. Priority inversion (how not to use semaphores)
      1. Understanding priority inversion
      2. An example-program, with priority inversion
    5. Mutexes
      1. Understanding mutexes
      2. An example-program, fixing priority-inversion
      3. Avoiding mutex-acquisition time-outs
    6. Race conditions
      1. Using mutexes and semaphores to avoid race conditions
      2. A race-condition example
    7. Software timers
      1. Understanding software timers
      2. Using Software timers
      3. Software-timer guidelines
    8. Summary
    9. Further reading
  10. 9 Intertask Communication
    1. Join our book community on Discord
    2. Understanding RTOS queues
      1. Simple queue: sending an item
      2. Simple queue: receiving an item
      3. Full queue: sending an item
      4. Empty queue: receiving an item
      5. Queues for inter-task communication
    3. Passing data through queues by value
      1. Passing one byte by value
      2. Passing a composite data-type by value
    4. Passing data through queues by reference
      1. When to pass by reference
      2. Important notes
    5. Task notifications
      1. Passing simple data using task notifications
      2. Other actions for task-notifications
      3. Comparing task-notifications to queues
    6. Summary
    7. Further reading
  11. 10 Drivers and ISRs
    1. Join our book community on Discord
    2. Introducing the UART
      1. Setting up the UART
    3. Creating a polled UART driver
      1. Understanding the example-program
      2. Running the example-program
      3. Analyzing the performance
      4. Pros and cons of a polled driver
      5. The use of polled drivers
    4. FreeRTOS tasks vs ISRs
      1. Differentiating between tasks and ISRs
      2. Calling FreeRTOS APIs from ISRs
      3. Configuring Interrupts for use with FreeRTOS
    5. Creating ISR-based drivers
      1. A queue-based driver
      2. A buffer-based driver
    6. Summary
    7. Further reading
  12. 11 Efficient Drivers and ISRs
    1. Join our book community on Discord
    2. Creating a DMA-based driver
      1. Introducing DMA
      2. Configuring the DMA peripheral
      3. Starting a DMA receive
      4. A buffer-based driver with DMA
      5. Performance analysis
    3. Creating a stream-buffer based driver
      1. Introducing stream buffers
      2. Introducing double-buffered DMA
      3. Implementing the driver
      4. Analyzing the performance
      5. Improving the stream buffer
    4. Choosing a driver model
      1. Questions to ask when choosing a driver model
      2. Rules of thumb for choosing a driver model
    5. Using third-party libraries and drivers
    6. Summary
    7. Further reading

Product information

  • Title: Hands-On RTOS with Microcontrollers - Second Edition
  • Author(s): Brian Amos, Jim Yuill, Penn Linder
  • Release date: February 2024
  • Publisher(s): Packt Publishing
  • ISBN: 9781803237725