none
5ms delay in a driver RRS feed

  • Question

  • Hi all,

    WinEC700 + iMX51.

    In my gpio driver i need to have a 5ms delay between two IO actions.

    My first try was by a Sleep(5), Sleep(10) and Sleep(20) but each of them produced 1.5sec of delay (is it correct to call Sleep(), is it a UserLevel function?).

    Other try with a empty for loop, but my guess is that the compiler strip it off: i didn't see ant delay with different numer of loops.

    How can i achieve the delay?


    SteMMo

    Friday, April 4, 2014 8:14 AM

All replies

  • Yes, Sleep may cause more delay than required (but may not be upto 1.5 second I guess).

    Whether you have a GPT timer (and GPT driver)?

    If yes, you can use GPT timer for delay...


    Keshava G N Member - Technical (Software), iWave Systems, Bangalore <http://iwavesystems.com> mailto: keshavagn AT iwavesystems DOT com

    Friday, April 4, 2014 8:39 AM
  • I agree on the abnormal time for the Sleep() ..

    I'm trying with

    { DWORD i=GetTickCount(); while((GetTickCount()-i)<10){}; };

    but again i have a very very small (if any) delay ..


    SteMMo

    Friday, April 4, 2014 9:09 AM
  • IMX51 has General purpose timers.

    You can configure one of them and poll for timeout value to get the precious delay.



    Check the GPT Driver of your BSP for reference.



    You need to set the clock source. Then configure the timout value and then start the timer.



    --- Misbah

    Senior Design Engineer T.E.S Electroni Solutions (Bangalore-India) www.tes-dst.com email-misbah.khan@tes-dst.com

    Friday, April 4, 2014 2:38 PM
  • to add up to Misbah comments; you can use  internal timers for delaying, configure it and wait for the interrupt. Remember that you're tickcount implementation is slowing down your system. Suppose the wait implementation runs on a priority 0 the complete system will wait for that specific delay, not giving other (low priority threads) any time. so using a timer implementation would be better...


    -- Good luck, Erwin Zwart--- Check out my blog: http://GuruCE.com/blog https://twitter.com/GuruCE_Embedded GuruCE Microsoft Embedded Partner http://GuruCE.com Consultancy, training and development services.

    Sunday, April 6, 2014 8:46 AM
  • I'm sorry ..

    The Sleep() function is working well.

    The problem was that the signal i was checking were powered after the delay, so i did not see that particular interval of time.


    SteMMo

    Tuesday, April 15, 2014 9:08 AM
  • Hi,

       You can use CEDDK StallExecution() routine - http://msdn.microsoft.com/en-us/library/ee482425.aspx
    But its timer should be calibrated properly during target boot-up.

    Tuesday, April 15, 2014 10:51 AM