ISR

michaeln32 wrote on Tuesday, June 21, 2016:

Hi
Can you please tell me the next questions :

1.What is System_Tick() interrupt priority in FREE RTOS ?

2.What is the range of Tasks priority in Free RTOS ?

3.What is the range of ISR priority in Free RTOS ?

4.Can in use librery functions in ISR ( for example memset in ISR) ?

Thank You

Michael

rtel wrote on Tuesday, June 21, 2016:

Which port are you using?

michaeln32 wrote on Wednesday, June 22, 2016:

FreeRTOS V8.2.1

rtel wrote on Wednesday, June 22, 2016:

I meant which MCU and compiler are you using FreeRTOS with?

michaeln32 wrote on Wednesday, June 22, 2016:

I am using MCU STM32F205RC.
Compiler: I am using Atollic

rtel wrote on Wednesday, June 22, 2016:

1.What is System_Tick() interrupt priority in FREE RTOS ?

Search for configKERNEL_INTERRUPT_PRIORITY on this page http://www.freertos.org/RTOS-Cortex-M3-M4.html and other pages on the website.

2.What is the range of Tasks priority in Free RTOS ?

http://www.freertos.org/RTOS-task-priority.html

3.What is the range of ISR priority in Free RTOS ?

That depends on the MCU as not all Cortex-M devices have the same priority ranges. See the link posted in answer to question 1 and the user manual for your STM32.

4.Can in use librery functions in ISR ( for example memset in ISR) ?

That depends on the library function. Juse when writing a bare metal application (with no OS) callilng memset() should be fine, but calling something like malloc() or printf() would be a very bad idea.

michaeln32 wrote on Wednesday, June 22, 2016:

Thank You !

michaeln32 wrote on Tuesday, July 19, 2016:

Hi
I am using MCU STM32F205RC.
Compiler: I am using Atollic
FreeRTOS V8.2.1
I have some questions:

  1. Is it possiable that ISR1 is stop running (preempted) by another ISR2 (when ISR2 have higher preority than ISR1) ?
  2. Is it possiable that ISR1 is stop running (preempted) by another ISR2 (when ISR2 have lower preority than ISR1) ?
  3. Is it possiable that ISR1 is stop running (preempted) by another ISR2 (when ISR2 have the same preority than ISR1) ?

Thank You

rtel wrote on Tuesday, July 19, 2016:

These are questions about the hardware, the answers to which are in the ARM documentation.

An interrupt can itself only be interrupted by another interrupt if that other interrupt has a higher priority.

michaeln32 wrote on Tuesday, July 19, 2016:

Thanks !

Can you please tell me what is the use of those functions

portSET_INTERRUPT_MASK_FROM_ISR();

portCLEAR_INTERRUPT_MASK_FROM_ISR();

michaeln32 wrote on Tuesday, July 19, 2016:

System Tick has higher priorty than ISR’s.

Can System Tick preempt ISR’s ?

How can I avoid race condition between ISR’s ?

Is it by using portSET_INTERRUPT_MASK_FROM_ISR ?

Thanks

edwards3 wrote on Tuesday, July 19, 2016:

portSET_INTERRUPT_MASK_FROM_ISR();
portCLEAR_INTERRUPT_MASK_FROM_ISR();

These are the equivalent of taskENTER_CRITICAL() and taskEXIT_CRITICAL() for us in ISRs and are used to avoid race conditions. You can call taskENTER_CRITICAL_FROM_ISR() and taskEXIT_CRITICAL_FROM_ISR() too which makes this more obvious. You will find examples of how the functions are used inside the queue.c file.

Can System Tick preempt ISR’s ?

System tick is an ISR so I think this has already been answered. Normally the system tick is the lowest priority ISR.

michaeln32 wrote on Thursday, July 21, 2016:

I never use the function memcpy in ISR.

But i use in in tasks.

Is it good or is it bad to use critical section with memcpy in tasks ?

For example :

	portENTER_CRITICAL();
    
	memcpy(&I2, &I1, sizeof(I1_FLSMsrEvnt));
                        
   portEXIT_CRITICAL();

rtel wrote on Thursday, July 21, 2016:

memcpy() itself does not need a critical section. The only time you
would need a critical section is if the buffer being memcpy’ed to or
from could be accessed by another task while the memcpy operation was in
progress.

If there are any occasions that you need to use a critical section in an
interrupt then use taskENTER_CRITICAL_FROM_ISR() and
taskEXIT_CRITICAL_FROM_ISR() in place of taskENTER_CRITICAL() and
taskEXIT_CRITICAL(). See
http://www.freertos.org/taskENTER_CRITICAL_FROM_ISR_taskEXIT_CRITICAL_FROM_ISR.html
for information on how to use the _FROM_ISR() versions.

michaeln32 wrote on Thursday, July 21, 2016:

Thank You.

Is a local variable of task remains his value after context switch to another task and back or the local variable of a task reinitilized to his original value ?