2017-11-08 06:48 AM
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)2017-11-08 07:56 AM
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
2017-11-08 11:08 AM
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 ...
2017-11-08 11:56 AM
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.
2017-11-08 12:31 PM
In STOP and STANDBY modes, system clocks are stopped - thus also SysTick.
2017-11-10 01:28 AM
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.
2018-06-14 12:02 PM
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
2018-09-04 09:02 PM
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!