Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Bug in the USART Harmony/FreeRTOS module(?)

Posted by wpp6 on February 27, 2019

Note: I posted this in the Microchip/Harmony forum, but I think it is a FreeRTOS problem.

Platform: Curiosity PIC32MZ EF (100 pin) with 2 Clik board slots WiFi4 Clik Board MPLABX IDE v4.20 Harmony 2.06 XC32 v2.10 FreeRTOS v10.0.1 (the default version selected in MHC)

The WiFi4 uses a USART (Tx/Rx) interface to the PIC32MZ host. MHC configures the USART and a RESET signal to control the WiFi4 board. The USART driver uses an interrupt with byte-mode at a 115200 baud rate.

I used MHC to configure 2 COM ports with the USB CDC library -- COM1 is a console port to enter AT commands for the WiFi4 Clik board and COM2 is a log port to display logging messages created during run-time.

I developed a superloop app that talks to the WiFi4 board. All of the interfaces and features work as expected. The logic running under the superloop is a little complicated because it relies on multiple state machines and a lot of flags to implement a command/response element. [This is a standard interface characteristic in many serial interfaces, such as Modbus.]

An RTOS simplifies the implementation of the command/response element by including delays and waits for the back-and-forth communications, so I converted the superloop logic to use the FreeRTOS module included in the Harmony distro. It crashed. After many hours of checking configurations, debugging (sometimes) showed the PC was in the port_asm.S file (a FreeRTOS source file). No documentation on what that file does but it appears to deal with some interrupt vector locations.

I was able to isolate the "bug" to be in the Rx and Error callbacks defined in the USART driver (byte-mode). If I commented out the callbacks, the code did not crash (but it did not execute properly). These same callbacks worked correctly in the superloop version.

Conclusion: there appears to be a bug in the USART Harmony/FreeRTOS module.

Bug in the USART Harmony/FreeRTOS module(?)

Posted by rtel on February 28, 2019


I'm afraid I have no idea how Harmony has written its drivers. A couple of hints though:

1) Did you include FreeRTOS through the harmony configurator? That may ensure the driver is compatible with FreeRTOS.

2) There are two ways of writing FreeRTOS compatible ISRs on the PIC32 - see the "interrupt service routines" section on this page to ensure you are following one of the methods: https://www.freertos.org/PIC32MZRTOSMIPS_M14K.html

Bug in the USART Harmony/FreeRTOS module(?)

Posted by wpp6 on February 28, 2019

Richard, thanks for responding.... 1. Yes, I am using the Harmony Configurator (MHC) and the FreeRTOS source code included in the standard Harmony 2.06 distro.
2. I will have to study the reference you provided. I really appreciste the good documentation that FreeRTOS provides. However, there is nothing that I can find that describes the port_asm.S and other .S files in the FreeRTOS source code. My theory is that the Harmony callbacks are not properly accounted for in FreeRTOS. Are they considered part of the ISR or not?

Bug in the USART Harmony/FreeRTOS module(?)

Posted by rtel on February 28, 2019

FreeRTOS just provides the context save/restore required on interrupt entry/exit, then the additional context save/restore should a context switch be required. Callbacks executed within the ISR should follow the description on the page link I provided - which basically just means to call the 'yield from ISR' function at the appropriate time.

Bug in the USART Harmony/FreeRTOS module(?)

Posted by wpp6 on March 4, 2019

Richard was correct. The bug is in the Harmony interrupt/byte mode driver. I posted a fix in the Microchip Harmony forum.

Bug in the USART Harmony/FreeRTOS module(?)

Posted by rtel on March 4, 2019

Thanks for taking the time to report back.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS v10.2.1 is available for immediate download. MIT licensed, includes 64-bit RISC-V, NXP Cortex-M33 demo, Nuvoton Cortex-M23 demo & STM32H745 dual core (AMP) demo.

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Cadence Tensilica Cortes

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers





STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner