freertos, ksdk and interrupts – accessing hardware

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

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

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

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).