# using isr before vTaskStartScheduler() starte

**URL:** <https://forums.freertos.org/t/using-isr-before-vtaskstartscheduler-starte/4458>\
**Category:** Kernel\
**Created:** [November 24, 2009, 1:08pm UTC](https://forums.freertos.org/t/using-isr-before-vtaskstartscheduler-starte/4458 "2009-11-24T13:08:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 24, 2009, 1:08pm UTC](https://forums.freertos.org/t/using-isr-before-vtaskstartscheduler-starte/4458/1 "2009-11-24T13:08:22Z")

</div>

**[bernd07](https://sourceforge.net/u/bernd07/)** wrote on [Tuesday, November 24, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/c547e06a/#6216):

Hi,

is it recommended to start an usart\_isr before the vTaskStartScheduler() will be started? Are there any kind of drawbacks? Which configuration would you suggest (using a semaphore or global variable within the isr)?

best regards  
Bernd

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 24, 2009, 1:15pm UTC](https://forums.freertos.org/t/using-isr-before-vtaskstartscheduler-starte/4458/2 "2009-11-24T13:15:26Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Tuesday, November 24, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/c547e06a/#0d9a):

Normally interrupts will be disabled before the scheduler is started. If you do use interrupts before the scheduler is started then you must ensure that no interrupt service routines try and perform a context switch, as to do so before the scheduler was initialized would cause a crash.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 24, 2009, 1:21pm UTC](https://forums.freertos.org/t/using-isr-before-vtaskstartscheduler-starte/4458/3 "2009-11-24T13:21:59Z")

</div>

**[bernd07](https://sourceforge.net/u/bernd07/)** wrote on [Tuesday, November 24, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/c547e06a/#e3f8):

Do you know a recommended way to enable the interrupts after starting the scheduler? If the usage of a global variable is perfect, where do I have to set this variable (to enable the interrupts)?

Or is it possible using the variable&nbsp; xSchedulerRunning = pdTRUE;  
-\> if true is correct, interrupts are enabled.

---

<div class="post-metadata">

**Author:** ![system](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7fc8fdb729c645aab5b20282bbe34e57cb407be6.jpeg) [@system](https://forums.freertos.org/u/system)\
**Post date:** [November 24, 2009, 1:31pm UTC](https://forums.freertos.org/t/using-isr-before-vtaskstartscheduler-starte/4458/4 "2009-11-24T13:31:13Z")

</div>

**[davedoors](https://sourceforge.net/u/davedoors/)** wrote on [Tuesday, November 24, 2009](https://sourceforge.net/p/freertos/discussion/382005/thread/c547e06a/#d028):

Interrupts will be enabled automatically when the first task starts running (assuming the FreeRTOS code is unchanged) so you don’t need to do anything from the application code. If you want the interrupt handler to only execute when the scheduler is running then testing xSchedulerRunning is a good method, but be careful as some ports require the task context to be saved before any C code executes, so before you can test the xSchedulerRunning value.
