FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [August 2012 Threads] Interrupts calling API before Scheduler startPosted by Fabien on August 16, 2012 Hi all,
I'm still working on my first FreeRTOS project and I would like to have some advices on Interrupts management.
I have enable my interrupts at the beginning of my code, before calling vTaskStartScheduler(). I have some troubles and I think this happen when an interrupts is calling FreeRTOS API before my Scheduler is running. In order to avoid this, I find 2 ways:
1 - Check for each interrupts the State of Scheduler by using xTaskGetSchedulerState. I will call FreeRTOS API (FromISR) Only if Scheduler is running (taskSCHEDULER_RUNNING)
2 - Enable my interrupts in one Task, In order to be sure that Scheduler is running.
Do you think that one way is better? Or if you know a cleanest way to do this, don't hesitate to explain it to me.
Thanks for your help, Best regards, Fabien
RE: Interrupts calling API before Scheduler startPosted by Richard on August 16, 2012 If you call FreeRTOS API functions before the scheduler is started (which you must do, to create at least one task, if nothing else), then the kernel will leave interrupts disabled for this very reason. It also makes no sense to try and unblock a task, or access a kernel primitive, etc. from an interrupt is the task or primitive does not exist or the scheduler is not running.
Method 1 could work depending on the port, but note that only API functions that end in "FromISR" are guaranteed to be interrupt safe, so by doing this you are outside the stated scope of use. Also, you don't really want to be making an extra function call on every interrupt once the scheduler is running.
Method 2 is the preferred method. You can enable peripheral interrupts before the scheduler has started, if you leave global interrupts disabled. The RTOS kernel will enable global interrupts automatically when the first task starts running.
Regards.
RE: Interrupts calling API before Scheduler startPosted by Fabien on August 16, 2012 Hi Richard
Thanks a lot for your (very fast) answer.
Method 1: Thanks for your explantion. I forget that only function with "FromISR" is guaranteed inside interrupt.
I will implement the second method.
Best regards, Fabien
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|