I can't achieve required task execution time

The following is a rough translation of @richard-damon’s suggestion to code -

/* Initialized when the FlashWritingTask is created. */
TaskHandle_t FlashWritingTaskHandle;

void FlashWritingTask( void * params )
{
    ( void ) params;

    for( ;; )
    {
        /* Wait for a notification to write to flash. */
        ulTaskNotifyTake( pdTRUE, portMAX_DELAY  );

        /* Write to flash. */
    }
}

/* Simulation - Kick off the FlashWritingTask every 100 ms. */
void SimulationTask( void * params )
{
    TickType_t xLastWakeTime;
    const TickType_t xFrequency = pdMS_TO_TICKS( 100 );

    ( void ) params;

     /* Initialise the xLastWakeTime variable with the current time. */
     xLastWakeTime = xTaskGetTickCount();

    for( ;; )
    {
        /* Wait for the next cycle. */
        vTaskDelayUntil( &xLastWakeTime, xFrequency );

        /* Kick off the FlashWritingTask. */
        xTaskNotifyGive( FlashWritingTaskHandle );
    }
}

/* Bosch IMU BMI160 IRQ - Kick off the FlashWritingTask every 100 ms. */
void Bosch_IMU_BMI160_ISR( void )
{
    xHigherPriorityTaskWoken = pdFALSE;

    vTaskNotifyGiveFromISR( FlashWritingTaskHandle, &( xHigherPriorityTaskWoken ) );

    portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
}

1 Like