Enabling interrupts before FreeRTOS scheduler starts on K64f

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Enabling interrupts before FreeRTOS scheduler starts on K64f

2,645 次查看
unknowncoder
Contributor III

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? 

标签 (1)
3 回复数

2,290 次查看
mjbcswitzerland
Specialist V

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

2,290 次查看
unknowncoder
Contributor III

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

0 项奖励
回复

2,290 次查看
miduo
NXP Employee
NXP Employee

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.

0 项奖励
回复