STM32L0 stops waking from RTC wake up after a while - Page 1
Forum section: electronics / general

author: Boscoe
author_rank: Frequent Contributor
timestamp: September 27, 2018, 02:03:34 pm
content: Hi,I'm really just looking for some advice on how to debug this project or some pointers on the STM32 RTC.I'm developing some sensors that wake up on a periodic basis to take measurement, send the result over LoRa then go back to sleep. So, first off, it's hard for me to debug as it takes a long time to present the issue. I have 13 of this sensors on my bench testing their reliability.I have had 6 of them stop waking up from sleep after about 1-2 days of use (I have an LED turn on when they wake up). I'm sure they are not going into Hard Fault etc as the LED would stay on if they did, the LED simply never comes on, they never wake up.Every time they wake up I have to call the following function for them to wake up next time. I'm not sure if this is right.Code:HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, seconds - 1, RTC_WAKEUPCLOCK_CK_SPRE_16BITS);I generated the project from Cube and I'm using an external crystal for time keeping. When I try probing the boards that aren't working there isn't any signal at the crystal terminals. There is at the working ones but it disappears quickly. I know this is likely the capacitance of the probe but could this be a sign I have loaded the crystal too heavily? Could this be a source for my problem?Is there anything I should be aware of when using the RTC like this?Thanks for any help,Boscoe

author: mikerj
author_rank: Super Contributor
timestamp: September 27, 2018, 03:42:18 pm
content: Are you putting the micro to sleep in the same interrupt that gets called when it wakes up? If so you are never clearing the stack, so at some point it's guaranteed to fail.

author: Boscoe
author_rank: Frequent Contributor
timestamp: September 27, 2018, 04:02:14 pm
content: Thank you for your reply. Okay, I have just done a test, the RTC handler isn't called on wake up. So the following functions aren't called. Could this cause the issue?Code:HAL_RTC_AlarmIRQHandler(&hrtc);HAL_RTCEx_WakeUpTimerIRQHandler(&hrtc);

author: Boscoe
author_rank: Frequent Contributor
timestamp: September 29, 2018, 09:35:04 pm
content: I've been running the trial for 48 hours and one out of 11 has stopped waking up with the above code implemented. I really have no idea what this could be, perhaps power supply?

author: iMo
author_rank: Super Contributor
timestamp: September 30, 2018, 10:11:01 am
content: QuoteDo you mean the external 32kHz resonator?

author: Kjelt
author_rank: Super Contributor
timestamp: September 30, 2018, 07:44:19 pm
content: You could try if a complete reset (let the watchdog expire for instance) every 24 hours fixes the problem.If the problem is then solved you should look for memoryleaks, out of boundary writes etc. etc. or keep resetting it every 24hrs.These are one of those nasty things to find, because the reproduction time is so long

author: ogden
author_rank: Super Contributor
timestamp: September 30, 2018, 10:15:46 pm
content: Quote from: Kjelt on September 30, 2018, 07:44:19 pmIndeed watchdog shall be implemented.Quote from: Boscoe on September 27, 2018, 02:03:34 pmIf you are not sure or it does not work for you - just don't use use wake-up timer. Use period timer and some code instead. Power source most likely will not even notice if yourlow powerMCU will wake-up periodically (each second or minute) to check "are we there yet?" time and if not - just go back to sleep.QuoteYou maybe can probe output pin w/o trashing oscillation. Never touch input pin. Have you read AN2867 appnote?