Solved
STM32L462 delay in a microsecond(us)
HAL Library provide the HAL_Delay() for millisecond delay. I want to use micro second delay in STM32L4 so how I do it? Is it available in HAL library?
HAL Library provide the HAL_Delay() for millisecond delay. I want to use micro second delay in STM32L4 so how I do it? Is it available in HAL library?
I am done.
Added this dwt files in my project and working fine.
#ifndef DWT_STM32_DELAY_H
#define DWT_STM32_DELAY_H
#ifdef __cplusplus
extern "C" {
#endif
#include "stm32f1xx_hal.h"
uint32_t DWT_Delay_Init(void);
/**
* @brief This function provides a delay (in microseconds)
* @param microseconds: delay in microseconds
*/
__STATIC_INLINE void DWT_Delay_us(volatile uint32_t microseconds)
{
uint32_t clk_cycle_start = DWT->CYCCNT;
/* Go to number of cycles for system */
microseconds *= (HAL_RCC_GetHCLKFreq() / 1000000);
/* Delay till end */
while ((DWT->CYCCNT - clk_cycle_start) < microseconds);
}
#ifdef __cplusplus
}
#endif
#endifEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.