how to synchronize a freertos task with an interrupt using an event ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to synchronize a freertos task with an interrupt using an event ?

Jump to solution
9,338 Views
RaAolCortAcsMat
Contributor III

Do you have an example ?

Thanks

Labels (1)
1 Solution
7,570 Views
RaAolCortAcsMat
Contributor III

Erich Styger gives me the answer:

“The thing is: check your configMAX_SYSCALL_INTERRUPT_PRIORITY setting. You cannot call any RTOS API functions like xSemaphoreGiveFromISR() from an interrupt which is higher (numerically lower) than configMAX_SYSCALL_INTERRUPT_PRIORITY.

So  I change the priority, and it is working

NVIC_SetPriority(PIT_IRQ_ID, configMAX_SYSCALL_INTERRUPT_PRIORITY-1);

Thanks
Raul

View solution in original post

9 Replies
5,677 Views
danny30
Contributor I

I came in to drop a comment that the solution seemed to mark 

NVIC_SetPriority(PIT_IRQ_ID, configMAX_SYSCALL_INTERRUPT_PRIORITY-1);

as correct solution but it was not. That would actually put PIT_IRQ_ID to have an interrupt higher (numerically lower) than configMAX_SYSCALL_INTERRUPT_PRIORITY.

0 Kudos
Reply
5,675 Views
ErichStyger
Specialist I

yes, you have to remove that -1. Or add something to it.

0 Kudos
Reply
7,571 Views
RaAolCortAcsMat
Contributor III

Erich Styger gives me the answer:

“The thing is: check your configMAX_SYSCALL_INTERRUPT_PRIORITY setting. You cannot call any RTOS API functions like xSemaphoreGiveFromISR() from an interrupt which is higher (numerically lower) than configMAX_SYSCALL_INTERRUPT_PRIORITY.

So  I change the priority, and it is working

NVIC_SetPriority(PIT_IRQ_ID, configMAX_SYSCALL_INTERRUPT_PRIORITY-1);

Thanks
Raul

7,570 Views
josei
Contributor II

In KDS with PEx use: INT_SYS_SetPriority(PIT_IRQ_ID, configMAX_SYSCALL_INTERRUPT_PRIORITY-1);

0 Kudos
Reply
7,571 Views
xiangjunrong
Contributor IV

Hi, Raul,

I have downloaded the SDK_2.0_FRDM-K64F.zip, I have checked the directory, there are Freertos example in SDK.  For the event example, pls refer to the following example:

D:\Freescale\SDK2.0\boards\frdmk64f\rtos_examples\freertos_event\kds

For the interrupt example, you can refer to the directory:

D:\Freescale\SDK2.0\boards\frdmk64f\rtos_examples\freertos_swtimer\kds

You can post an event in the callback function of the swtimer, the task with the xEventGroupWaitBits() will be running with OS intervening..

You can refer to the Richard Barry reply for the task efficiency.

Hope it can help you.

BR

Xiangjun Rong

7,571 Views
RaAolCortAcsMat
Contributor III

Hi Xianju

My problem is to synchronize an interrupt with a task (in this case when a buffer is full).

I understand that with FREERTOS is necessary to use xSemaphoreGiveFromISR or another instruction FromISR, but it is necessary to change the priority of the interrupt peripheral.

If you have an example for the FRDM K64 board with SDK and FREERTOS.

Thanks in advance

Raul Cortes

0 Kudos
Reply
7,571 Views
FreeRTOS_org
Contributor IV

Information on how the interrupt priorities relates to FreeRTOS can be found on the following page: RTOS for ARM Cortex-M

0 Kudos
Reply
7,571 Views
FreeRTOS_org
Contributor IV

There are lots of ways of doing this - the best depends on your particular scenario.  The most efficient method would be to use a direct to task notification.  You will find an example of the scenario you highlight on this page.  You could also use a binary semaphore (see the example on the xSemaphoreGiveFromISR() page), counting semaphore, queue, event group, (others?), but as those methods use an intermediary object rather than sending the event directly to the task they will be less efficient.

7,570 Views
RaAolCortAcsMat
Contributor III

Hi Richard

My problem is to synchronize an interrupt with a task (in this case when a buffer is full).

I understand that with FREERTOS is necessary to use xSemaphoreGiveFromISR or another instruction FromISR, but it is necessary to change the priority of the interrupt peripheral.

If you have an example for the FRDM K64 board with SDK and FREERTOS.

Thanks in advance

Raul Cortes

0 Kudos
Reply