2023-01-05 10:18 AM
I'm using the STM32L010 chip and am trying to write a routine to allow me to get a delay of 10uS. But when I try to add this:
/**
* @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);
}
to my header file I get this error:
../Core/Inc/dwt_stm32_delay.h: In function 'DWT_Delay_us':
../Core/Inc/dwt_stm32_delay.h:30:29: error: 'DWT' undeclared (first use in this function)
30 | uint32_t clk_cycle_start = DWT->CYCCNT;
I guess I'm not INCLUDEing the proper header file. I added "#include "stm32l0xx_hal.h" but that didn't help.
Any ideas?
Thanks,
Richard
Solved! Go to Solution.
2023-01-05 10:47 AM
Welcome, @Community member, to the community!
DWT stands for Data Watchpoint and Trace and is usually included in STM32 based on Cortex-M3, Cortex-M4/-M33 and Cortex-M7, but not in the Cortex-M0+ of the STM32L010.
Does it answer your question?
Regards
/Peter
2023-01-05 10:47 AM
Welcome, @Community member, to the community!
DWT stands for Data Watchpoint and Trace and is usually included in STM32 based on Cortex-M3, Cortex-M4/-M33 and Cortex-M7, but not in the Cortex-M0+ of the STM32L010.
Does it answer your question?
Regards
/Peter
2023-01-05 11:10 AM
Thanks Peter I guess that explains what I did wrong.
2023-01-05 11:18 AM
If the problem is solved, please mark this thread as answered by selecting Select as best, as also explained here. This will help other users find that answer faster.
Good luck!
/Peter