Quality RTOS & Embedded Software

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




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) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists