cancel
Showing results for 
Search instead for 
Did you mean: 

How update RTC in lrwan library ?

Fabien LETORT
Associate II
Posted on November 08, 2017 at 15:48

I don't understand how rtc library work in lrwan module.

Some code (as the Utilities/timeServer.c) use tick (from rtc) value to get elapsed time.

By using TimerGetCurrentTime then a little bit letter TimerGetElapsedTime we can have elapsed time in ms.

But if we update the rtc betwwen this two call.... this does not work....

So my question is : How rtc can be update in this library ? To put it at the correct current datetime.

#rtc #murata-cmwx1zzabz-lrwan1-(ver1.1.1)
7 REPLIES 7
Posted on November 08, 2017 at 16:56

Well they seem to have chosen to use the RTC instead of the SysTick for the software time base, I'd assume because it is lower power or some CM0 don't have SysTick.

Personally, I'd refactor the thing, and use SysTick for the time base and free the RTC up to do Time/Date

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on November 08, 2017 at 19:08

Could also be because they are timing across low-power 'sleeps' - and RTC is the most power-efficient way to do this ... ?

EDIT

In which case, changing the RTC time might not matter: because you will only do that while the CPU is awake - so the RTC is not being used for a delay at that time ...

Posted on November 08, 2017 at 19:56

I haven't mined that deep into the L0, does it sleep with the WFI in the same way for RTC vs SysTick?

A lot of the timing seems to be at the millisecond level, I could see value at multiple seconds.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on November 08, 2017 at 20:31

In STOP and STANDBY modes, system clocks are stopped - thus also SysTick.

Posted on November 10, 2017 at 09:28

Ok, thanks for this discussion.

Ok so i think that RTC is used as the library and the given example use STOP and STANBY mode a lot.

So i will make a method to can update the RTC properly. This method will :

  - update the alarm A (use by the delay wakeup over RTC library feature)

  - so update the delay alarm reference time

I am really surprise that i don't find a such solution already implemented somewhere....

With this, the delay registered should not be modified. The library TImeServer.c managing the delay queue/list should not be disturb. The only remaining problem is the method 

TimerGetElapsedTime that could have a really bigger reply than the waited one.

for this remaining problem, I think that st should refactor these two methods in their library/example : 

TimerGetCurrentTime/TimerGetElapsedTime. I think that TimerGetCurrentTime should give a reference to keep internal reference on the given time to can update it, if rtc is updated. In this way if this reference is later used in the TimerGetCurrentTime method, the correct elapsed time will be computed.

I found also a bug in the st example project. As the systick is not used,  

HAL_InitTick is redefined locally to do nothing. BUT HAL_GetTick is not redefined anywhere in the code given by st.

In such way, actually, all project given with the lrwan library are bugged. All HAL synchronous method that are using a timeout can not return on this timeout on strange isssue : the HAL_GetTick method return always 0. THis is the cas of the SPI_WaitOnFlagUntilTimeout method that are used by the lrwan library. THis is the case of of the HAL method used in rtc also..... It will be the case on I2C or UART method if you add theses feature to given project.

Posted on June 14, 2018 at 19:02

I have the same problem regarding 

HAL_GetTick, which makes timeout buggy.

I don't know how to fix this now... 

Do you find some solution?

Thanks

Huzaifah Limbada
Associate II

Hey @Fabien LETORT​ 

"I found also a bug in the st example project. As the systick is not used,  

HAL_InitTick is redefined locally to do nothing. BUT HAL_GetTick is not redefined anywhere in the code given by st."

I'm also facing this problem which leads to timeout at "SPI_WaitOnFlagUntilTimeout" and even sometimes my systick is stopped,

So i made some changes according to other projects implemented from CubeMx and now i'm facing RxTimeout error because my device is unable to join the networks.

If anyone have idea about this please suggest me.

Thank you!