2019-07-19 07:07 AM
Hi guys,
I'm using STM32LO and i try to implement a code who aquire data of a sensor every 10 second in a fix day in a week. The rest of the time, the ship is sleeping.
I'm trying to do that interruption with RTC and i configure the RTC and program my interrupt routine but my code is not working. The RTC doesn't counts seconds or minute sand by the way, i have no interruptions.
I put the code of the RTC initialisation and the function who does the interruption below. I hope you can help me to find why the RTC is not working correctly.
RTC Initialisation :
The infinity loop and the function that is called when the alarm make an event call back :
I don't know if my method is correct but the use of RTC seems right for my application.
Thanks you
Tim
2019-07-19 09:32 AM
Make sure the clocks are enabled and ticking.
Make sure the RTC is advancing.
Use the LSE. I don't use L0 parts, but double check the LSI isn't turned off in low power modes.
Test the 1Hz interruption.
Review the example code in the CubeL0 libraries, perhaps for an EVAL board with a known working design.
2019-07-19 10:14 AM
Not familiar with HAL calls but it looks like you've set Alarm A to interrupt once a week at midnight. With all alarm masks on the alarm triggers once a week at the day of week:hour:minute:second set in the register. The alarm register is based on a fixed time, periodic once a minute (only seconds masked), once an hour (minutes enabled) or once a day (hours enabled). If you use weekday then it's once a week.
If you want 10 seconds then you'll have to configure Alarm A for masking seconds only, set a seconds value for 10 seconds in the future, and repeat the process after every alarm interrupt occurs.
If you use an RTOS with soft timers it's a lot easier to set up a periodic soft timer that triggers every 10 seconds.