Solved
STM32L031K6 Nucleo and DWT?
I have a STM32L031K6 Nucleo Board...
I want to use the DWT.. but I become this errors:
../Core/Src/../Inc/stm32_delay.h:35:30: error: 'DWT' undeclared (first use in this function)
uint32_t clk_cycle_start = DWT->CYCCNT;How can I Use DWT or Enable it? I Use STM32CubeIDE...
My Function:
#ifndef INC_STM32_DELAY_H_
#define INC_STM32_DELAY_H_
#ifdef __cplusplus
extern "C" {
#endif
#ifndef __STM32L0xx_HAL_H
#include "stm32l0xx_hal.h"
#endif
/**
* @brief Initializes DWT_Cycle_Count for DWT_Delay_us function
* @return Error DWT counter
* 1: DWT counter Error
* 0: DWT counter works
*/
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
#endif /* INC_STM32_DELAY_H_ */Thanks guys..
