Advice wanted: FreeRTOS + Harmony 3 + UART

We are converting a large production firmware package from Zilog eZ80 to PIC32MX795F512L. The current design uses cooperative scheduling via an OS we wrote ourselves. We would like to use preemptive scheduling via FreeRTOS and Harmony 3’s framework, where useful, primarily to become familiar with these and eventually to take advantage of the Harmony 3 device libraries.

The present challenge is about UARTs. We need 4 serial async-channels, 3 for RS485 and 1 for RS232. The baud rates are 9600 and 57600. At the moment we are not looking for demo code, (and I guess because Harmony 3 is new, there seems little available in any case), but rather advice on how to proceed. We see these alternatives:

  1. Write the ISRs / Device drivers ourselves. Perhaps plib_uartx.c would be helpful as a starting point.

  2. Use the Harmony 3 code and adapt it to our needs. This seems to omit much in the way of FreeRTOS integration.

  3. Create ISRs to work with FreeRTOS, not using much from Harmony 3.

  4. Fully integrate and use features from Harmony 3 and FreeRTOS, not that we are even sure what that would look like in practice.

We look forward to suggestions and ideas,

I’m sure it is a matter of preference, but personally I would start with your option 4 just to get things up and running and see the UARTs working. Then I would analyse things like performance, latency, run-time model, etc. to see if the result is suitable for my application. If I needed higher performance, I would then hand tune the ISRs to do something like use DMAs, etc., and refactor the tasks so the task that handles the UARTs spends most of its time in the Blocked state and is just woken up when an ISR says there is something useful to do (so not polling, not using arbitrary block times, and not consuming any CPU cycles unless there was something to do) - all that would be easier to adapt from working code than write from scratch though.

@rtel Good advice, this is what I am trying to do. Unfortunately there is a problem apparently between Harmony 3 and FreeRTOS related to processing Interrupts. Have not given up yet, but it’s very frustrating. (see recent post)

Hi Robert,
The way I approached this for my project is as follows. I have a dummy Harmony 3 project where I configure the peripherals and generate code and a separate project where I have my application code with FreeRTOS. When I need to access a new peripheral, as I add functionality/ debug another section of the target, I go to the dummy project, configure the peripheral to my requirements, generate the code and copy it across to my application code base.
If there are any ISRs, I modify as per our other thread.

It’s far from ideal, but it stops having to review the code merge every time I add a peripheral/library to the project.