cancel
Showing results for 
Search instead for 
Did you mean: 

Use RTC counter to realize the function of time keeping, but the error is very big

Lucky Dog
Associate III

Background: The MCU chip I use is stm32L476RG. Since the MCU usually needs to work in the standby mode and will wake up within 2s, I want to count the time the MCU is in the standby mode each time.

Implementation method: The clock source of RTC is LSI, PREDIV_A[6:0] in RTC_PRER in the register is 15, PREDIV_S[14:0] is 32767, that is to say, the load value in the register RTC_SSR will subtract 1 every about 488.3us. I used systick to implement a delay function to verify the accuracy of RTC for timing, read the value of RTC_SSR before and after the delay, denoted as cnt1 and cnt2 respectively, timing time T=(cnt1- cnt2)*488.3.

Question: The picture below shows the actual situation where I use systick delay and RTC timing. I would like to know why this happens.

0693W00000NsmRAQAZ.pngRTC related configuration:

0693W00000NsmShQAJ.png

4 REPLIES 4
gbm
Lead III

Check the datasheet - LSI frequency and accuracy.

0693W00000NsqvnQAB.png 

0693W00000NsqwlQAB.pngAs can be seen from the above two figures, the LSI clock frequency is in a certain range, so we cannot know the exact clock frequency??

Yes.

JW​

Thank you very much