cancel
Showing results for 
Search instead for 
Did you mean: 

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

RCooke88
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
Peter BENSCH
ST Employee

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

In order 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.

View solution in original post

3 REPLIES 3
Peter BENSCH
ST Employee

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

In order 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.
RCooke88
Associate III

Thanks Peter I guess that explains what I did wrong.

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

In order 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.