Skip to main content
Selim Sagir
Associate III
November 6, 2019
Question

How I can make or demonstrate miliseconds up counter on RTC?

  • November 6, 2019
  • 4 replies
  • 1581 views

Hello to everyone,

I am reading time with RTC on my board but milisecond is downcounter as mention on datasheet. I need to see milisecond to up counter on serial port. How can i do it?

Thanks.

This topic has been closed for replies.

4 replies

berendi
Principal
November 6, 2019

How about subtracting it from the maximum value ?

Selim Sagir
Associate III
November 6, 2019

thank you, yes but i wonder is there any way without bulk for processor.

Jack Peacock_2
Associate II
November 6, 2019

The RTC subseconds register is the counter for the RTCCLK synchronous prescaler. Read the RTC->PRER register and extract the lower 15-bit bits for the prescaler period. When you read the subseconds down counter, subtract the value from the prescaler period. That's your up counter in units of whatever the RTC sync frequency is.

You still have to convert from prescaled RTCCLK tick to actual milliseconds. As an example, given a 32.768KHz LSE as the clock source, the async prescale is 32 and sync prescale is set to 1024 (close to 1ms). When you read subseconds you get a down count from 0 to 1023. Subtract it from 1023 to get the up count. For actual milliseconds it's simple algebra: upcount * 1000 / 1024 = ms upcounter (and remember your numerical analysis course...always multiply before dividing).

Jack Peacock

Selim Sagir
Associate III
November 6, 2019

Thank you for good explain bro.