Quality RTOS & Embedded Software

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


[PIC32] DMA + Int + Rtos: advices wanted

Posted by Erupter on February 3, 2012
I have a working application that is getting complicated and I'm thinking about moving it to FreeRTOS.
Now my main concern is that it uses DMA triggered by UartRX INT to move a bunch of bytes to an array which then gets shuffled to an SD via SPI.

What are the problems I may face by leaving this mechanism as it is while integrating the rest of the app in FreeRTOS?
I could set up the buffers as global variables, so that they wouldn't bog any process' stack (I use 4K buffers, so quite big to shuffle around). Would this be sufficient?

I currently use FatFS and it takes about 5 ms to write an entire buffer.
It is pure code flowing, no DMA as I couldn't find a working implementation and I couldn't make my own (if anyone wanted to share one, I would be most appreciating!).
So it must (i think) remain operational for the whole transfer, I don't know what would happen if the process got preempted.

RE: [PIC32] DMA + Int + Rtos: advices wanted

Posted by MEdwards on February 4, 2012
Where are your 4K buffers allocated now? If they are on the stack, then you could leave them on the stack in your FreeRTOS version so long as you create the task with a big enough stack. It would probably be easier to have them as file scope variables though to make sure the stack variable does not vanish when the DMA is still using it.

The mechanism you describe is quite normal I think, and FreeRTOS will work fine with that. The DMA will do its own thing whatever, you just have to consider how the DMA interrupt is handled. How you do that will depend on its time criticality, and which FreeRTOS port you are using.

If you are using SPI to the SD card then getting interrupted should not be a problem. What will be a problem is having two tasks access the SD card at the same time, and in FreeRTOS you can prevent that using a simple mutex.

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

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

Latest News

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

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

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

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