Skip to main content
Visitor II
January 5, 2023
Solved

Which header file do I need to include to resolve this issue?

  • January 5, 2023
  • 2 replies
  • 1189 views

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

    This topic has been closed for replies.
    Best answer by Peter BENSCH

    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

    2 replies

    Technical Moderator
    January 5, 2023

    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

    RCooke88Author
    Visitor II
    January 5, 2023

    Thanks Peter I guess that explains what I did wrong.

    Technical Moderator
    January 5, 2023

    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