2021-12-16 03:58 AM
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?
2021-12-16 03:58 AM
2021-12-16 04:34 AM
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
2021-12-16 05:23 AM
Related:
https://community.st.com/s/question/0D53W00001FnhWcSAJ/defined-things-called-undeclared
2021-12-16 11:29 PM
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?
2021-12-16 11:31 PM
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?
2021-12-16 11:31 PM
2021-12-16 11:32 PM
2021-12-17 06:48 AM
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