Skip to main content
Senior
February 24, 2024
Solved

Does HAL Provides a Delay Function for One Micro Second?

Hi,

I am looking for a delay function for  1 us, HAL_Delay provides 1 ms, is there one in HAL or somewhere else?

Regards

Chao

    This topic has been closed for replies.
    STTwo-32
    STTwo-32Best answer
    ST Technical Moderator
    February 24, 2024

    Hello @Chao 

    HAL_Delay is able to provide minimum 1 ms delay, but when it comes to microseconds, there isn’t any predefined function to create 1 us delay in HAL Library. You have to create your own function. You can do that using a Timer for example you can refer to this post.

    Best Regards.

    STTwo-32 

     

    To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

    2 replies

    STTwo-32
    STTwo-32Best answer
    ST Technical Moderator
    February 24, 2024

    Hello @Chao 

    HAL_Delay is able to provide minimum 1 ms delay, but when it comes to microseconds, there isn’t any predefined function to create 1 us delay in HAL Library. You have to create your own function. You can do that using a Timer for example you can refer to this post.

    Best Regards.

    STTwo-32 

     

    To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
    Pavel A.
    February 24, 2024

    Actually HAL_Delay (as implemented) cannot even do  a 1 ms delay... but one can provide better implementations.