Quality RTOS & Embedded Software

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




Loading

freertos, ksdk and interrupts - accessing hardware

Posted by peter-au on January 19, 2017

Using freertos and ksdk on a Cortex M4. Using kdsk if your accessing hardware from inside and outside interrupts do you need to add disable and enable interrupts around the hardware access in the main thread?

Like this: void main(void) { InitEverything(); enableInterruptXYZ(); while (1) { disableInterruptXYZ(); kdsk-accessHardware(); enableInterruptXYZ(); //do other stuff } }

InterruptXYZ-Handler() { kdsk-accessHardware(); }


freertos, ksdk and interrupts - accessing hardware

Posted by rtel on January 20, 2017

I'm not sure why KSDK would be relevant to your question other than if you are asking about the thread safety of the libraries that come with it (and hence if you need to disable interrupts). If that is the case then I'm afraid the answer is I have no idea, and you would either have to look at the implementation of the libraries, or ask the vendor that supplied the libraries.


freertos, ksdk and interrupts - accessing hardware

Posted by peter-au on January 20, 2017

Hi, say kdsk-accessHardware() calls Kinetis SDK (kdsk) function GPIO_WritePinOutput(). kdsk-accessHardware() is called from the main loop and within the interrupt. Then inside main() do I you need to include the lines disableInterruptXYZ() and enableInterruptXYZ()?

ie if the code inside GPIOWritePinOutput() in main() is running and the interrupt decides to run - and also run GPIOWritePinOutput() whilst GPIO_WritePinOutput() is partially complete - is that a problem?


freertos, ksdk and interrupts - accessing hardware

Posted by rtel on January 20, 2017

I still don't know anything about how the KSDK libraries are implemented, so my previous answer still holds. They might have that sort of critical section in them already, which would be doubtful, but if you are just toggling a pin you might find it is atomic anyway depending on how the registers are implemented.

Never disable and enable interrupts directly though, use taskENTERCRITICAL() and taskEXITCRITICAL() (Google them to find the docs on the FreeRTOS.org site or download the reference manual, or download the book for a broader picture).


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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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