Delay in S32K358

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delay in S32K358

184 Views
Guna
Contributor I

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
}
}

0 Kudos
Reply
1 Reply

166 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Guna

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.

0 Kudos
Reply