Skip to main content
Anand Krishnan
Associate
April 6, 2017
Question

how to put delay without using timers?

  • April 6, 2017
  • 5 replies
  • 2025 views
Posted on April 06, 2017 at 15:58

.

    This topic has been closed for replies.

    5 replies

    Tesla DeLorean
    Guru
    April 6, 2017
    Posted on April 06, 2017 at 17:20

    Use DWT_CYCCNT ?

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Technical Moderator
    April 6, 2017
    Posted on April 06, 2017 at 17:30

    Hi

    Krishnan.Anand

    ,

    If you are HAL user, you can use HAL_Delay function.

    Imen

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Tesla DeLorean
    Guru
    April 6, 2017
    Posted on April 06, 2017 at 17:53

    That tends to use a TIM or SysTick, and a software based counter providing millisecond level granularity.

    I sense the OP wants software spin loops, or sub-microsecond. The vague 'title as a question' leaves a lot to be desired. Ask better/smarter questions.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    S.Ma
    Principal
    April 6, 2017
    Posted on April 06, 2017 at 19:18

    Be more explicit. What is the real need behind? As some say, please elaborate. Making delays without timer can bring exotic answers such as put a cap on a gpio, charge it with the gpio, then switch it as exti input to trigger an interrupt or even a stopped clock restart...

    shingadaddy
    Senior
    April 6, 2017
    Posted on April 06, 2017 at 23:33

    For...

    While...

    Hold the reset button longer....

    Exotic yes.

    antonius
    Associate III
    April 7, 2017
    Posted on April 07, 2017 at 02:18

    That will make a delay :

    void Delay(int nTime)

    {

        unsigned int i;

        unsigned long j;

        for(i = nTime;i > 0;i--)

            for(j = 1000;j > 0;j--);    

    }

    or

    in CubeMX

    1s delay = HAL_Delay(1000);

    Tesla DeLorean
    Guru
    April 7, 2017
    Posted on April 07, 2017 at 03:31

    The use of the volatile keyword is strongly recommended so the compiler/optimizer doesn't fold the loop. These types of loops should generally be avoided

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    antonius
    Associate III
    April 7, 2017
    Posted on April 07, 2017 at 03:35

    what does 'volatile keyword' mean ? do you mean nTime ?