News:

Attention: For security reasons,please choose a user name *different* from your login name.
Also make sure to choose a secure password and change it regularly.

Main Menu

Generate time delay

Started by sonic, March 22, 2018, 04:14:36 PM

Previous topic - Next topic

sonic

Hello,
Not sure if I can get help about this on this forum or not!

We want to generate time delay between controlling GPIO pins. The easier approach would be to create a loop, but it is not a way to generate a Time delay.

Here is what we are doing,

XGpio_DiscreteWrite(&output, TRIG, 0x1); // Start trigger
for( i = 0; i < Delay; i++){
}
XGpio_DiscreteWrite(&output, TRIG, 0x0); // Stop trigger

Can someone guide us regarding what would be the best way to use delay?

Appreciate your help!

Best Regards

Oleksandr Kiyenko

Hello,

for correct delay generation better to use platform library functions like "udelay" or "MB_sleep" (depending on platform and OS).
Your example, in most cases, will be optimized by compilator and not produce required delay.

Best regards
Oleksandr Kiyenko

sonic

Hi,

Thank you for the reply.

usleep(delay);  function worked.

Yes, The generating time delay using a loop is not a way to do it, Everytime program compiles it changed.!

Thank you

Best regards