Hello,
I have been looking through some of the demo code for K64f when using FreeRTOS. I notice one of the example code enables global interrupts before the RTOS scheduler starts. Using this "EnableGlobalIRQ(0)" function.
I don't understand why interrupts need to be enable before the scheduler starts. If anything this can lead to alot of problems.
To my understanding FreeRTOS will enable interrupts when the scheduler starts.
Can anyone give some insight into this?
Hi Desmond
FreeRTOS itself will disable interrupts when its initialisation starts (taskENTER_CRITICAL()) and won't enable them again until after the initialisation is complete (in prvPortStartFirstTask() from xPortStartScheduler() [see static UBaseType_t uxCriticalNesting = 0xaaaaaaaa; which ensures they remain blocked during the initialisation to ensure no context switch can be triggered].
The pre-initialisation part is something supplied in addition to the kernel which may or may not make use of interrupts before FreeRTOS initialisation.
Generally there should be no harm in enabling interrupts before, if the environment (which is supplying the port) needs to enable them before.
Regards
Mark
Kinetis: http://www.utasker.com/kinetis.html
Kinetis K64:
- http://www.utasker.com/kinetis/FRDM-K64F.html
- http://www.utasker.com/kinetis/TWR-K64F120M.html
- http://www.utasker.com/kinetis/TEENSY_3.5.html
- http://www.utasker.com/kinetis/Hexiwear-K64F.html
Including integrated FreeRTOS v9.0.0 port for all Kinetis parts (KE, KEA, KL, K etc.)
Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M
For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html
The example may not have been well thought out, but FreeRTOS will enable global interrupts I can see this happening in the assembly code by calling "cpsie" instruction.
This happens on prvPortStartFirstTask().
Hi,
I am not sure what code you mentioned. Does the code with CMSIS or KDS? Would you mind to attach the code here and I will help to check. Thanks.