cancel
Showing results for 
Search instead for 
Did you mean: 

There is no DWT in the M0/M0+ kernel.

ZKURT.1
Senior

Hi. I am using stm32l01c6tx. I want to use a very simple microsecond function. Libraries I have added below. "DWT" "CTRL" etc. when I included the libraries. It says not defined. But they are all in the "core_cm4.h" library. This library is in Drivers-> CMSIS->Include.

The STM32L010C6TX uses M0+ cores, not M4 cores. so it uses "core_cm0plus.h".

There is no DWT in the M0/M0+ kernel. My question is DWT, CTRL etc. What can I use instead? Can I use these functions for STM32L0 Series?

8 REPLIES 8
ZKURT.1
Senior

header

Cortex-M0/M0+ (or, more precisely, any ARMv6-M implementation, but that's probably only Cortex-M0 and M0+) does have a DWT unit, but it's different from the Cortex-M3/4/7 one, and does not have the CYCCNT register, which you are looking for.

You have to use some of the timers for this sort of functionality, or SysTick, but given 'L0 have no 32-bit timers, this is a bit less convenient, you have to account for the wraparound at 16 bits.

JW

TDK
Guru

Related:

https://community.st.com/s/question/0D53W00001FnhWcSAJ/defined-things-called-undeclared

If you feel a post has answered your question, please click "Accept as Solution".

So how can I do it using a timer? https://www.youtube.com/watch?v=SqC0IhLKJ9o&ab_channel=ControllersTech I did as it shows in the video but the program didn't work. Most likely APB2, prescaler, counter mode etc. I have an error in the values. How do I write those values?

So how can I do it using a timer? https://www.youtube.com/watch?v=SqC0IhLKJ9o&ab_channel=ControllersTech I did as it shows in the video but the program didn't work. Most likely APB2, prescaler, counter mode etc. I have an error in the values. How do I write those values?

 
 

You should be able to in-line multiple images in a single post

You forked the thread here

https://community.st.com/s/question/0D53W00001GNEPRSA5/timer-with-stm32l010c6tx-mikroseconds

You can get an equivalent free running counter by setting the ARR = 0xFFFF (Period) and PSC = 0 (Prescaler),this will run at the APB clock frequency, and TIM->CNT will be the equivalent to DWT->CYCCNT, but only 16-bit wide, so do math with uint16_t values.

If you set PSC = (APB MHZ)-1, the count will count at 1 MHz (1us) instead

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..