FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [December 2012 Threads] 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).
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|