• Menu
  • Product
  • Email
  • PDF
  • Order now
  • Developing Basic Applications With FreeRTOS on TM4C MCUs

    • SPMA085 June   2022 TM4C1230C3PM , TM4C1230C3PM , TM4C1230D5PM , TM4C1230D5PM , TM4C1230E6PM , TM4C1230E6PM , TM4C1230H6PM , TM4C1230H6PM , TM4C1231C3PM , TM4C1231C3PM , TM4C1231D5PM , TM4C1231D5PM , TM4C1231D5PZ , TM4C1231D5PZ , TM4C1231E6PM , TM4C1231E6PM , TM4C1231E6PZ , TM4C1231E6PZ , TM4C1231H6PGE , TM4C1231H6PGE , TM4C1231H6PM , TM4C1231H6PM , TM4C1231H6PZ , TM4C1231H6PZ , TM4C1232C3PM , TM4C1232C3PM , TM4C1232D5PM , TM4C1232D5PM , TM4C1232E6PM , TM4C1232E6PM , TM4C1232H6PM , TM4C1232H6PM , TM4C1233C3PM , TM4C1233C3PM , TM4C1233D5PM , TM4C1233D5PM , TM4C1233D5PZ , TM4C1233D5PZ , TM4C1233E6PM , TM4C1233E6PM , TM4C1233E6PZ , TM4C1233E6PZ , TM4C1233H6PGE , TM4C1233H6PGE , TM4C1233H6PM , TM4C1233H6PM , TM4C1233H6PZ , TM4C1233H6PZ , TM4C1236D5PM , TM4C1236D5PM , TM4C1236E6PM , TM4C1236E6PM , TM4C1236H6PM , TM4C1236H6PM , TM4C1237D5PM , TM4C1237D5PM , TM4C1237D5PZ , TM4C1237D5PZ , TM4C1237E6PM , TM4C1237E6PM , TM4C1237E6PZ , TM4C1237E6PZ , TM4C1237H6PGE , TM4C1237H6PGE , TM4C1237H6PM , TM4C1237H6PM , TM4C1237H6PZ , TM4C1237H6PZ , TM4C123AE6PM , TM4C123AE6PM , TM4C123AH6PM , TM4C123AH6PM , TM4C123BE6PM , TM4C123BE6PM , TM4C123BE6PZ , TM4C123BE6PZ , TM4C123BH6PGE , TM4C123BH6PGE , TM4C123BH6PM , TM4C123BH6PM , TM4C123BH6PZ , TM4C123BH6PZ , TM4C123BH6ZRB , TM4C123BH6ZRB , TM4C123FE6PM , TM4C123FE6PM , TM4C123FH6PM , TM4C123FH6PM , TM4C123GE6PM , TM4C123GE6PM , TM4C123GE6PZ , TM4C123GE6PZ , TM4C123GH6PGE , TM4C123GH6PGE , TM4C123GH6PM , TM4C123GH6PM , TM4C123GH6PZ , TM4C123GH6PZ , TM4C123GH6ZRB , TM4C123GH6ZRB , TM4C123GH6ZXR , TM4C123GH6ZXR , TM4C1290NCPDT , TM4C1290NCPDT , TM4C1290NCZAD , TM4C1290NCZAD , TM4C1292NCPDT , TM4C1292NCPDT , TM4C1292NCZAD , TM4C1292NCZAD , TM4C1294KCPDT , TM4C1294KCPDT , TM4C1294NCPDT , TM4C1294NCPDT , TM4C1294NCZAD , TM4C1294NCZAD , TM4C1297NCZAD , TM4C1297NCZAD , TM4C1299KCZAD , TM4C1299KCZAD , TM4C1299NCZAD , TM4C1299NCZAD , TM4C129CNCPDT , TM4C129CNCPDT , TM4C129CNCZAD , TM4C129CNCZAD , TM4C129DNCPDT , TM4C129DNCPDT , TM4C129DNCZAD , TM4C129DNCZAD , TM4C129EKCPDT , TM4C129EKCPDT , TM4C129ENCPDT , TM4C129ENCPDT , TM4C129ENCZAD , TM4C129ENCZAD , TM4C129LNCZAD , TM4C129LNCZAD , TM4C129XKCZAD , TM4C129XKCZAD , TM4C129XNCZAD , TM4C129XNCZAD

       

  • CONTENTS
  • SEARCH
  • Developing Basic Applications With FreeRTOS on TM4C MCUs
  1.   Abstract
  2.   Trademarks
  3. 1Introduction
  4. 2How to Install
    1. 2.1 Update the FreeRTOS Version in the TivaWare Directory
    2. 2.2 Adding FreeRTOS Hardware Driver Files for TM4C LaunchPads
  5. 3Architecture for TM4C FreeRTOS Examples
    1. 3.1 Proper Clock Configuration
    2. 3.2 How to use Hardware Interrupts Alongside the FreeRTOS Kernel
  6. 4Example Project Walkthroughs
    1. 4.1 Download and Import the Examples
    2. 4.2 Kernel Examples
      1. 4.2.1 Example: hello
      2. 4.2.2 Example: notify_example
      3. 4.2.3 Example: queue_example
      4. 4.2.4 Example: semaphore_example
      5. 4.2.5 Example: blinky_queue
      6. 4.2.6 Software Timer Examples
        1. 4.2.6.1 Example: timer_sw_oneshot
        2. 4.2.6.2 Example: timer_sw_periodic
        3. 4.2.6.3 Example: timer_sw_led_counter/timer_sw_rgb
    3. 4.3 ADC Examples
      1. 4.3.1 Example: adc_multi_channel
      2. 4.3.2 Example: adc_timer_trigger
    4. 4.4 Hardware Timer Examples
      1. 4.4.1 Example: timer_hw_oneshot
      2. 4.4.2 Example: timer_hw_periodic
      3. 4.4.3 Example: timer_hw_pwm
    5. 4.5 UART Example
      1. 4.5.1 Example: uart_thread_safe
    6. 4.6 Watchdog Example
      1. 4.6.1 Example: watchdog
  7. IMPORTANT NOTICE
search No matches found.
  • Full reading width
    • Full reading width
    • Comfortable reading width
    • Expanded reading width
  • Card for each section
  • Card with all content

 

APPLICATION NOTE

Developing Basic Applications With FreeRTOS on TM4C MCUs

Abstract

FreeRTOS is a real-time operating system for embedded systems. It has been widely ported to many architecture platforms due to its compact size and being distributed under free open source licensing. This application report will demonstrate how to use the FreeRTOS kernel on the Texas Instruments TM4C family of Arm® Cortex®-M4F microcontrollers. Example projects are provided to demonstrate how to use fundamental FreeRTOS features and how to build basic real-world applications for TM4C's peripherals.

The source code for all example projects discussed in this application report can be downloaded from the following link http://www.ti.com/lit/zip/spma085.

Trademarks

TivaWare™ and Code Composer Studio™ are trademarks of Texas Instruments.

Arm® and Cortex® are registered trademarks of Arm Limited (or its subsidiaries) in the US and/or elsewhere.

All trademarks are the property of their respective owners.

1 Introduction

The microcontroller market continues to see a steady increase in the utilization of embedded real-time operating systems (RTOS) to manage applications. The increased focus and need for RTOS solutions has led to a number of open source RTOS offerings including the widely used FreeRTOS. This application report will introduce how to use FreeRTOS with the TM4C Arm Cortex-M4F microcontroller series and provides another supported option for users to select from when choosing an RTOS to use on TM4C devices.

Included with this application report are example projects for both the TM4C123x and the TM4C129x device families. Many of these projects are based on the bare metal examples provided in the TivaWare Software Development Kit (SDK). The TivaWare™ SDK includes Driver Library (DriverLib) APIs for all peripherals that are the building blocks for any application on a TM4C microcontroller. The provided example projects illustrate how to use DriverLib APIs within the FreeRTOS kernel to create simple real-world applications with basic device peripherals. Coverage for additional peripherals is planned for future collateral releases.

The kernel examples are centered on showcasing fundamental RTOS features using the FreeRTOS kernel on TM4C micrcontrollers. These examples keep the usage of TM4C peripherals to a minimum and provide a simple starting point for new users to learn how to use the following key features of the FreeRTOS kernel.

  • Scheduler: Preemptive scheduler that guarantees the highest priority thread is running
  • Communication Mechanism: Semaphores, Queues, Notifications
  • Critical Region Mechanism: Mutexes
  • Timing Services: Software Timers

The peripheral examples do not introduce new RTOS concepts but instead extend on those foundations to build basic real-world applications. These examples demonstrate key concepts such as how to plug in hardware interrupts into the kernel and how to minimize overhead when inside a hardware interrupt that is not controlled by the RTOS scheduler. The concepts used in these examples can be adapted to many other peripherals. The peripherals that are demonstrated in this report are as follows with additional peripheral examples planned for future collateral.

  • Analog to Digital Converter (ADC)
  • General-Purpose Input/Output (GPIO)
  • Pulse Width Modulator (PWM)
  • Timer
  • Universal Asynchronous Receiver/Transmitter (UART)
  • Watchdog

2 How to Install

The following steps demonstrate how to download the latest version of TivaWare and FreeRTOS:

  1. Download the latest TivaWare SDK from here and follow the installer instructions. If using the default installation path, the TivaWare SDK will be installed at C:\ti\TivaWare_C_Series-2.2.0.295. For the TivaWare directory structure, see Figure 2-1 (and notice there is already a third_party/FreeRTOS directory). The existing FreeRTOS installation in the TivaWare library is version 8.2.3. This needs to be updated to the latest version.
    GUID-20220608-SS0I-9GDS-VCWK-GWRPVTWCGTQM-low.png Figure 2-1 TivaWare Directory Structure
  2. Download the latest version of FreeRTOS from the official download source here. At the time of the publishing of this application report, the latest version of FreeRTOS is Version 202112.00, as shown in Figure 2-2. All examples provided with this application report have been created and validated using that version.
    GUID-20220608-SS0I-XPRZ-LRWF-VNGRMBBJ4X4Q-low.png Figure 2-2 FreeRTOS Download Site
  3. Unzip the FreeRTOS zip file and install to a temporary directory. View the FreeRTOS directory structure and notice the FreeRTOS folder and other folders and files, as shown in Figure 2-3.
    GUID-20220608-SS0I-3DLN-LRQX-RP87FMDDCQZQ-low.jpg Figure 2-3 FreeRTOS version 202112.00 Directory Structure

2.1 Update the FreeRTOS Version in the TivaWare Directory

The FreeRTOS folder from the new download will need to be either moved or copied to the TivaWare library under C:\ti\TivaWare_C_Series-2.2.0.295\third_party. Make sure to first rename or move the existing FreeRTOS folder in the TivaWare library if there is a desire to retain it as a backup as shown in Figure 2-4.

GUID-20220608-SS0I-VG86-HXDK-QNM9KT7TNCR6-low.png Figure 2-4 Updated TivaWare for New FreeRTOS Installation

2.2 Adding FreeRTOS Hardware Driver Files for TM4C LaunchPads

The collateral provided include new hardware driver files that were created to provide a single source for basic pinout configurations for each LaunchPad Evaluation Kit. The files are located under the Driver Files directory. These files are referenced in all examples that use device pins, so this step is required as part of the first time setup.

The rtos_hw_drivers.c and rtos_hw_drivers.h files for each specific LaunchPad should be copied into the TivaWare folders for that LaunchPad under the drivers directory. For EK-TM4C123GXL this path would be TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c123gxl\drivers and for EK-TM4C1294XL this path would be TivaWare_C_Series-2.2.0.295\examples\boards\ek-tm4c1294xl\drivers.

 

Texas Instruments

© Copyright 1995-2025 Texas Instruments Incorporated. All rights reserved.
Submit documentation feedback | IMPORTANT NOTICE | Trademarks | Privacy policy | Cookie policy | Terms of use | Terms of sale