cancel
Showing results for 
Search instead for 
Did you mean: 

CAN I read STM32L's RTC counter?

19786345
Associate
Posted on December 01, 2011 at 04:58

Hi,all

   I want to use the STM32L's RTC counter as system logic clock as I did using STM32F, but I found no way to do this. My application needs low power and high time resolution(about 100us). Any suggestions will be appreciated 🙂

Thanks.

#rtc-counter #stm32l-discovery
1 REPLY 1
Posted on December 02, 2011 at 16:35

I want to use the STM32L's RTC counter as system logic clock as I did using STM32F, but I found no way to do this. My application needs low power and high time resolution(about 100us). Any suggestions will be appreciated 🙂

Over what kind of periods? If the core is clocking over the periods you want, you could always look at the core's cycle counter. I haven't check it on the L1 series, but it's been part of the trace unit bolted to all ST's other M3 cores.

As I recall you can deal with nearly a minute with around 14 ns resolution. Clearly depending on your system clock.

                 // From http://forums.arm.com/index.php?showtopic=13949

                volatile unsigned int *DWT_CYCCNT     = (volatile unsigned int *)0xE0001004; //address of the register

                volatile unsigned int *DWT_CONTROL    = (volatile unsigned int *)0xE0001000; //address of the register

                volatile unsigned int *SCB_DEMCR         = (volatile unsigned int *)0xE000EDFC; //address of the register

                *SCB_DEMCR = *SCB_DEMCR | 0x01000000;

                *DWT_CYCCNT = 0; // reset the counter, read this register for clock ticks

                *DWT_CONTROL = *DWT_CONTROL | 1 ; // enable the counter

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