Hi Everyone,
I need to use a delay of 100ms in my project. Currently I'm creating a function inside that function there is a for loop with 313 iterations which is considered as 1ms. whether it will work or do I need to some changes. I am using S32K358 for my project.
This is the function I am using
void delay_ms(unsigned int delay)
{
for(unsigned int x=0; x<delay; x++)
{
for(unsigned int time=0;time<313; time++); //1ms delay
}
}
I suggest you use a timer to complete delayed actions
This delay method (void delay_ms(unsigned int delay)) needs to be configured according to the system clock and will be affected by interrupts and cannot achieve precise delay requirements.
If you need to measure the actual execution time of the delay function, you can use an oscilloscope to test the actual delay time by using TOGGLE GPIO.