FreeRTOS Support Archive

The FreeRTOS support forum can be used for active support both from Amazon Web Services
and the community. In return for using our software for
free, we request you play fair and do your bit to help others! 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.

Functioning FreeRTOS Project within MPLAB Harmony Framework

I have started working with FreeRTOS and the PIC32MZ EC StarterKit ( PIC32MZ2048ECH144 onboard ) about a month ago.
I wrote a working application that uses ADC inputs and outputs data to a LCD. The drivers are custom since the XC32 plib is not supported for the MZ family as far as I understood.

At this point i wanted to send data from the application to my PC and store this data in a .txt file to use it i.e. in Excel. For any keywords that came to my mind Google wanted me to use the Harmony Framework with its new plib and drivers. I downloaded Harmony and setup the provided FreeRTOS demo that worked fine. I cleaned this demo application and fit my own application into the Harmony structure.

After I managed it to compile with no errors or warnings, I ran the app and saw ...nothing...

Before I start listing any code: I use MPLAB X IDE v2.05, XC32 v1.32 Compiler, MPLAB Harmony v08002b with the stated PIC32MZ2048ECH144 on the EC StarterKit. Before using the integrated FreeRTOS version, my application was running with FreeRTOSV8.0.0

While debugging I found that the application initializes, runs, resets and starts over again from main(). This is caused by a "Simple Tlb Refill Exception" which I caught overwriting the weak simpletlbrefillexception_handler(void) provided by ?! MIPS32 ?!.
I stepped out of this handler and returned to the FreeRTOS queue.c function "xQueueGenericSend( [..] )". Further single step tells me this function is called by a
"xSemaphoreGive( xASemaphoreHandle );" function that is NOT located in an ISR ( unless Harmony does smt. creepy ).

Functioning FreeRTOS Project within MPLAB Harmony Framework

From the way your line numbers are jumping around, am I right in assuming that compiler optimisation is being used, at least in the part that is building the FreeRTOS source files. If so I would recommend turning optimisation off while you are debugging, otherwise you may find what you are viewing in the debugger confusing or misleading, and not really know which line of code is causing the exception.

It may be related to the compiler optimisation, if that is being used, but it would seem unlikely that the exception came from:

unless pxQueue was not actually pointing to a queue, as all the code is doing is dereferencing the point twice to perform a comparison.

Do you have configASSERT() defined? If so then an assert would be triggered if pxQueue was null, which would leave the possibility of it being corrupted, but with a value other than NULL. What do you see if you view pxQueue in the debugger - does it look feasible?

Functioning FreeRTOS Project within MPLAB Harmony Framework

Let me first thank you for providing FreeRTOS. I very much also enjoyed reading the Tutorial book.

You where right and again right!

I turned off the optimization-level ( to 0 ). Also I forgot that I before had commented out the configAssert( x ) link to vAssertCalled( [..] ) in FreeRTOSConfig.h.

Now as you expected the lines are executed in an proper order, also configAssert( x ) is called and hangs in a loop now.

This means the SemaphoreHandle must be NULL in that point...

While writing this I found the bug and the problem is solved! The application is running. But I want to explain what was the problem even though I dont think somebody else would run into the wall as I did now:

I need to explain a bit more about what I'm doing with this Semaphore:

I have two tasks that can send information to a GateKeeperTask for LCD output via a queue. Just one of them should send information at a time. Therefore another task that queries the digital inputs, hands out a Semaphore to just one of those two tasks (I called the Semaphores as "Token"). Now there is a kind of Context switch performed when pressing a hardware switch on the starter board. I use this functionality to toggle between a TaskManager output and my analog measurements output on the LCD. The time between a Semaphore beeing handed out and the task actually taking it ( I used vTaskDelayUntil( [..] ) since a Task resumes working, just the LCD output requires the Semaphore ), can be perfectly used for a Loading screen or the like.

Now it is correct that this Semaphore that creates the assert is initialised as NULL!
This is because my Semaphore is created when "prvTaskManager( void *pvParam )" is called the first time (before entering the loop).

While copying the initialization from the old application to the new Harmony "APP_Initialize()" I forgot to start the TaskManager task, so the semaphore was never created. Unfortunately the application is also set to initially switch the Display to TaskManager so I can read the cpu and heap, otherwise this error would have occured after pressing a hardware switch.