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

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

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

跳至解决方案
7,681 次查看
RaAolCortAcsMat
Contributor III

Do you have an example ?

Thanks

标签 (1)
1 解答
5,913 次查看
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

在原帖中查看解决方案

9 回复数
4,020 次查看
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 项奖励
4,018 次查看
ErichStyger
Senior Contributor V

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

0 项奖励
5,914 次查看
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

5,913 次查看
josei
Contributor II

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

0 项奖励
5,914 次查看
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

5,914 次查看
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 项奖励
5,914 次查看
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 项奖励
5,914 次查看
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.

5,913 次查看
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 项奖励