Recent

Author Topic: micro-Sleep for raspberry Pi  (Read 3685 times)

emjtech

  • New Member
  • *
  • Posts: 28
    • Global R&D ltd
micro-Sleep for raspberry Pi
« on: December 23, 2018, 03:49:39 pm »
Hi
I need to add a small delay on Raspberry Pi 3B+ (to allow an external data bus to stabilize) 1 uS will be enough.
Is there some simple procedure like
uSleep(t)
being t miroseconds (or nanoseconds) ?
or I need to write one?
If I need to write one can anyone recommend the simplest way ?
Thanks.
Thanks
Eli Jacob

Thaddy

  • Hero Member
  • *****
  • Posts: 19431
  • Glad to be alive.
Re: micro-Sleep for raspberry Pi
« Reply #1 on: December 23, 2018, 04:42:29 pm »
Use the fpsystem unix call for the linux kernel nanotimer. I will add a small example later. Note this will likely loose precision over longer periods of time (larger than a second).
Any "programmer" that knows only one programming language is not a programmer

jamie

  • Hero Member
  • *****
  • Posts: 7832
Re: micro-Sleep for raspberry Pi
« Reply #2 on: December 23, 2018, 07:12:45 pm »
1 us isn't much..

just execute some code between  :D
The only true wisdom is knowing you know nothing

emjtech

  • New Member
  • *
  • Posts: 28
    • Global R&D ltd
Re: micro-Sleep for raspberry Pi
« Reply #3 on: December 25, 2018, 11:40:06 am »
Thaddy thanks, I will look for it, if you have an example it will be great
jamie thanks, that is exactly what I did , I calibrated that in a Raspberry Pi 3B+ the loop

for i:= to oneMicro do;

takes approximately 1uS for oneMicro:=17;

but I don't fill great about that because :
1-is not precise
2-it needs a different calibration value if I use a different machine ,for example  Raspberry Pi 3B (no +)
Thanks
Eli Jacob

AlexTP

  • Hero Member
  • *****
  • Posts: 2725
    • UVviewsoft
Re: micro-Sleep for raspberry Pi
« Reply #4 on: December 25, 2018, 12:28:54 pm »
You have GetTickCount64, call it in loop until enought ticks.

Thaddy

  • Hero Member
  • *****
  • Posts: 19431
  • Glad to be alive.
Re: micro-Sleep for raspberry Pi
« Reply #5 on: December 25, 2018, 12:40:40 pm »
You have GetTickCount64, call it in loop until enought ticks.
GetTickCount64 is too low resolution for micro timing.
Any "programmer" that knows only one programming language is not a programmer

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: micro-Sleep for raspberry Pi
« Reply #6 on: December 25, 2018, 04:55:40 pm »
What about fpNanoSleep?

 

TinyPortal © 2005-2018