cancel
Showing results for 
Search instead for 
Did you mean: 

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

Selim Sagir
Associate III

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.

4 REPLIES 4
berendi
Principal

How about subtracting it from the maximum value ?

Jack Peacock_2
Senior III

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

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

Selim Sagir
Associate III

Thank you for good explain bro.