Hi, I'm working on a FreeRTOS (I just start to use it, so I'm a beginner) project in wish we want to use an external 32 MHz crystal. The program has a task that should be executed during a period of time of 125ms. Using the internal clock, the task executes in the expected time. However, when I implemented the HFXO, the execution time is almost 3.5*expected time (~430ms). Here's part of the code how I initialize the clock based on Clock driver - legacy layer:
extern TaskHandle_t TSK_test_handle;
/*Event handler of the code*/
static void clock_hfck_rdy( nrf_drv_clock_evt_type_t event )
{
switch(event)
{
case NRF_DRV_CLOCK_EVT_HFCLK_STARTED:
break;
case NRF_DRV_CLOCK_EVT_LFCLK_STARTED:
break;
case NRF_DRV_CLOCK_EVT_CAL_DONE:
break;
case NRF_DRV_CLOCK_EVT_CAL_ABORTED:
break;
default:
break;
}
}
static void init_clock( void )
{
APP_ERROR_CHECK( nrf_drv_clock_init());
static nrf_drv_clock_handler_item_t clock_handler =
{
.event_handler = clock_hfck_rdy
};
nrf_drv_clock_hfclk_request(&clock_hfck_rdy);
}
int main(void)
{
nrf_delay_ms(100);
init_clock();
UNUSED_VARIABLE(xTaskCreate(
TSK_test,
"TSK_test",
configMINIMAL_STACK_SIZE+100,
NULL,
2,
&TSK_test_handle));
/*Other tasks....*/
vTaskStartScheduler();
while (true)
{
}
}
/////////////////////////////////////////////////////
/*EXTERNAL MODULE - Task definition*/
#define SAMPLE_TIME_TICK 125
TaskHandle_t TSK_test_handle;
void TSK_test(void)
{
vTaskDelay(250);
TickType_t xLastWakeTime = xTaskGetTickCount();
while(True)
{
/*Some code...*/
vTaskDelayUntil( &xLastWakeTime, SAMPLE_TIME_TICK );
}
}
Any help to figure out what I'm doing wrong to make the program run slower with the external crystal will be very appreciated.
Thanks!