Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


PIC32 Bug - vTaskEnterCritical()?

Posted by Mark Samarin on December 7, 2012
When the scheduler is not running, vTaskEnterCritical() sets the system priority to 4.
But vTaskExitCritical() does not restore the priority to the previous state when the scheduler is off.

So if these functions are called with the scheduler off, you end up with a different priority and possibly many missing hairs from your head!!! Since the uChip USB functions set the ISR IPL to 4 (in code, not just the ISR header) this effectively disables the USB interrupt.

RE: PIC32 Bug - vTaskEnterCritical()?

Posted by MEdwards on December 7, 2012
This is a deliberate ploy for all the ports, not just PIC32. Once you start calling FreeRTOS functions interrupts are left disabled to ensure an interrupt that tries a context switch cannot happen. Interrupts are reenabled automatically when the scheduler starts.

RE: PIC32 Bug - vTaskEnterCritical()?

Posted by Mark Samarin on December 16, 2012
This confuses me a bit. Isnt the whole idea of the EnterCritical()/ExitCritical functions to provide control when a context switch can occur? If the scheduler has not started yet, what type of context switch would be harmful? To leave the CPU in a different state when finishing the call set seems wrong IMO.

I modified the ExitCritical function to restore the priority because I have some things that must run before and during the scheduler running. Are you suggesting that this is unsafe?

RE: PIC32 Bug - vTaskEnterCritical()?

Posted by Dave on December 16, 2012
It is only unsafe if:

1) You install and enable an interrupt.
2) The interrupt handling function executes and uses a FreeRTOS API function that modifies the state of the FreeRTOS kernel (which has not yet been initialized) or attempts a context switch (when the kernel has not been initialized).

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

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists