nndpkz wrote on Thursday, June 07, 2018:
Hi guys,
I am trying to implement example from 9.3 chapter from Mastering The FreeRTOS Real-Time Kernel book. I am using ZYNQ-7000. Now, since I didn’t check how to simulate software interrupts on Zynq, I just decided to simply call a function from which I will call xTaskNotifyGive. This is just an illustration example. This is what I have:
int main( void )
{
time_t xTimeNow;
xil_printf( "Hello world!\n\r" );
time( &xTimeNow );
prvSRand( (uint32_t)xTimeNow );
vPortInstallFreeRTOSVectorTable( );
Xil_DCacheEnable( );
xTaskCreate( vPlaybackTask, "Playback", 1024, NULL, configMAX_PRIORITIES - 4, NULL );
xTaskCreate( vPeriodicTask, "Periodic", 1024, NULL, configMAX_PRIORITIES - 6, NULL );
/* Start the RTOS scheduler. */
xil_printf( "vTaskStartScheduler\n" );
vTaskStartScheduler( );
return 0;
}
static
void vExampleInterruptServiceRoutine( void )
{
xTaskNotifyGive( vPlaybackTask );
}
static
void vPeriodicTask( void *pvParameters )
{
while( 1 )
{
vTaskDelay( xInterruptFrequency );
xil_printf("Periodic task - About to generate / simulate an interrupt!\n");
vExampleInterruptServiceRoutine();
xil_printf("Periodic task - Interrupt generated!\n");
}
}
static
void vPlaybackTask( void *pvParameters )
{
const TickType_t xMaxExpectedBlockTime = xInterruptFrequency + pdMS_TO_TICKS( 10 );
uint32_t ulEventsToProcess = 0;
while( 1 )
{
ulEventsToProcess = ulTaskNotifyTake( pdTRUE, xMaxExpectedBlockTime );
if( ulEventsToProcess != 0 )
{
while( ulEventsToProcess > 0 )
{
xil_printf( "Playback task -> processing -> run DMA.\n" );
ulEventsToProcess--;
}
}
}
}
however, ulTaskNotifyTake never returns a value different from 0. I have also checked that xTaskNotifyGive() is actually called.
Maybe I am missing something obvious here?
Best regards,
Nenad
P.S. The same example from Chapter 6.4 which uses binary semaphore instead of Task Notify is working as expected.