This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

random delay .!!

Hi ..

I need help regarding writing a C code for a random delay that its duration is within 0.2 - 0.8 miliSeconds?

Parents
  • Are we expected to submit some random lines of code?

    You have to realize that you can't implement a random function unless you have any data somewhere to randomize from. You (!) have to figure out where that data can come from (# of received serial characters, time stamps when they where received, ...).

    We can't do such things - we don't even know your platform...

    As soon as you have figured out where you can get something random to base the delay on, then it should be trivial for you to implement the actual delay. Once more: Implementing a delay requires knowledge about the platform. We don't know what timers are available, or how fast the processor is if the delay should busy-loop...

Reply
  • Are we expected to submit some random lines of code?

    You have to realize that you can't implement a random function unless you have any data somewhere to randomize from. You (!) have to figure out where that data can come from (# of received serial characters, time stamps when they where received, ...).

    We can't do such things - we don't even know your platform...

    As soon as you have figured out where you can get something random to base the delay on, then it should be trivial for you to implement the actual delay. Once more: Implementing a delay requires knowledge about the platform. We don't know what timers are available, or how fast the processor is if the delay should busy-loop...

Children