2020-10-13 09:00 AM
In order to keep track of the Time of Day I would like to implement a time tick.
None of the timers run (other than the virtual timer) when the bluetooth module goes into low power mode. I would like the CPU to only wake up when there is an external event or one of the virtual timers expire. I do not want the virtual timer to wake the entire CPU just to keep incrementing a timer every second.
Is there a method to determine elapsed time from the slow running oscillator
The following does not seem to work consistently.
preSleep = HAL_VTimerGetCurrentTime_sysT32();
BlueNRG_Sleep(sleepMode, WAKEUP_IO10, wakeup_level);
postSleep = HAL_VTimerGetCurrentTime_sysT32();
diff = HAL_VTimerDiff_ms_sysT32(postSleep,preSleep);
incTimeStamp(diff);
2021-04-19 02:05 PM
Hi, have you found an answer for this question? I am interested too
2021-04-19 06:07 PM
Well, the answer to your question depends on what host processor you are running on. If you are using an STM32 MCU, then you need to initialize, run and use the RTC module.
2021-04-19 09:53 PM
In my case bluenrg-2 is host (standalone SoC Mode) and unfortunately as far as I know there is no RTC in low power mode. Hence need to use virtual timer. I wonder if this is accurate enough to track time for longer periods.
2021-04-20 06:19 AM
Did you RTFM, or am I missing something?
Incredulous at your response, I just downloaded the BlueNRG-2 datasheet and I see that the RTC ticks in sleep mode and that sleep mode gets you down to 2.1-uA
2021-04-20 07:45 AM
No need to be rude. Looking at examples provided by st https://www.st.com/resource/en/user_manual/dm00298232-bluenrg1-bluenrg2-development-kits-stmicroelectronics.pdf '20.9 RTC examples' I can see that RTC in sleep mode is only simulated by virtual timer. At least thats what API in DK is supporting, no wake-up source from rtc. If you could prove otherwise I would be happy as I would like to use this functionality...
2021-04-20 09:40 AM
No intention to be impolite, but I do get frustrated by lazy posts clogging up the community, so my rhetorical questions can be blunt.
Anyway, it looks like your BlueNRG-2 is based on the Cortex-M0, so you could download the STM32CubeM0 and look for HAL and Low Level examples of running the RTC.
2021-04-21 02:20 PM
Guys calm down!
So my question was originally posted for the BlueNRG-1 devices and the RTC does NOT tick down in sleep mode. I ended up using the virtual timer to check the elapsed time based on the system tick. I would then increment my CPU RTC manually based on the system tick. I had set the Bluetooth ADV interval to 10 seconds. Using this method I was able to maintain 2 seconds accuracy over 60 minutes at least.
I did take into account that the VTimers overflow every 52 seconds or so hence the ADV interval of 10 seconds.
msSinceStart = HAL_VTimerDiff_ms_sysT32(HAL_VTimerGetCurrentTime_sysT32(),sysTimeStart);