albert6186 wrote on Saturday, May 18, 2019:
Hi, everyone.
I have a question which cost me several days and I still can’t solve it.
I use tick hook function as a timer. My tick interval is 10ms. In my tick hook function, I create a counter as 3 seconds timer. When the counter reaches 3 seconds I will send a task notification to my daemon task.
My problem is the task can’t get that event notification. I have read the vPortTickISR code. At the end of the ISR, there is a call for switchcontext. That is the same as portYield. So I think the event notify should be ok. But, it is not. If I create a 3 seconds timer using xTimerCreate, and in the timer, I send the same event notification to the same task, the notification will be ok. I want to know why to send event notification won’t work in tick hook.
Thank you very much!
The code snippets are here:
main()
{
…
////Daemon task
xTaskCreate(Daemon , “Daemon” , 256 , NULL , (tskIDLE_PRIORITY + 1) , &xHandlDaemon);
…
}
void Daemon ()
{
uint32_t ulEventStatus;
for ( ;; )
{
xTaskNotifyWait(0 , ULONGMAX , &ulEventStatus , portMAX_DELAY);
if(ulEventStatus & Event_3s)
{
…
}
…
}
gDaemonTimerCnt = 300;
void vApplicationTickHook( void )
{
if(gDaemonTimerCnt)
{
gDaemonTimerCnt–;
}
if(gDaemonTimerCnt == 0)
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
extern __no_init TaskHandle_t xHandlDaemon;
xTaskNotifyFromISR( xHandlDaemon , DaemonEvent, eSetBits , &xHigherPriorityTaskWoken );
}
}