I build the xTaskNotifyFromISR()
, and xTaskNotifyWait()
structure, but the weird thing is that my task is executed only once.
So I have a 1 sec software timer paused:
TimerHandle_t timerHndl1Sec;
timerHndl1Sec = xTimerCreate( "timer1Sec", /* name */
pdMS_TO_TICKS(1000), /* period/time */
pdTRUE, /* auto reload */
(void*)0, /* timer ID */
vTimerCallback1SecExpired); /* callback */
static void vTimerCallback1SecExpired(TimerHandle_t pxTimer) {
beep_alarm();
xTaskNotify( TaskLcdTimerHandle, 0, eNoAction);
}
And my rotary ISR looks like this:
ISR(PORTC_PORT_vect) {
if(PORTC_IN & (PIN1_bm)) {
PORTC_INTFLAGS = PORT_INT1_bm;
} else {
PORTC_INTFLAGS = PORT_INT1_bm;
}
if(PORTC_IN & (PIN3_bm)) {
PORTC_INTFLAGS = PORT_INT3_bm;
} else {
PORTC_INTFLAGS = PORT_INT3_bm;
}
rotary_tick();
xTaskNotifyFromISR( TaskLcdTimerHandle, 0, eNoAction, NULL );
}
So at startup my vTimerCallback1SecExpired() isn’t running yet.
As soon as I rotate the rotary knob, my task is notified and executed only once and starts the software timer.
I hear the beep_alarm(); inside vTimerCallback1SecExpired() so software timer is running, but my task isn’t doing anything.
My task looks like this:
static void tsk_lcdtimer(void *pvParameters)
{
while (1) {
xTaskNotifyWait( 0xffffffff ,
0xffffffff ,
NULL,
portMAX_DELAY ); /* Block indefinitely. */
LCDWriteTime(10);
if(rotary_getPosition() > 0)
{
//_positionExt--;
xTimerStart(timerHndl1Sec, 0);
} else {
xTimerStop(timerHndl1Sec, 0);
}
tilt_check_orientation();
printf("LCD:%u\n", uxTaskGetStackHighWaterMark( NULL ));
//xTaskNotifyStateClear( NULL );
}
}
Does xTaskNotifyWait()
mark the task state non-pending automatically?