I have written a function below which helps generate a time delay in micro-seconds. i plan to set time delays in the rage of 2-5 micro-seconds.
void Delay_Us(unsigned int Us)
{
// Convert microseconds us into how many clock ticks it will take
Us *=(SYS_CLK_FREQ / 1000000) / 2; // Core Timer updates every 2 ticks
_CP0_SET_COUNT(0); // Set Core Timer count to 0
// Wait until Core Timer count reaches the number we calculated
while (Us > _CP0_GET_COUNT());
}
I have FREERTOS configured in the code. I am wondering how the function defined will affect its total time duration if FreeRTOS functions vTaskStartScheduler() and xTaskCreate are executed independently during the small interval.
Specifications:
Compiler: XC32,
IDE: MPLAB X IDE v4.05
Chip: PIC32MZ2048EFG144
I would appreciate some guidance.
Thank you,
Kenny