Skip to main content
mibou23
Associate II
July 19, 2019
Question

Interruption each 10 seconds with RTC

  • July 19, 2019
  • 2 replies
  • 2605 views

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 : 0690X000009YvlDQAS.png

0690X000009YvlIQAS.png

The infinity loop and the function that is called when the alarm make an event call back :

0690X000009YvlNQAS.png I don't know if my method is correct but the use of RTC seems right for my application.

Thanks you

Tim

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
July 19, 2019

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.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Jack Peacock_2
Associate II
July 19, 2019

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.