2017-11-30 03:51 AM
Hi,
I am developing a prototype board which does a set of programmed task and goes to standby mode. It has both clock interrupt and pin wake up interrupt to wake the controller up from the standby mode. I am facing two issues:
1. I'm not able to write a program to differentiate between the clock interrupt and pin wake up interrupt (as the behavior should be different, according to the interrupt raised). I have referred to RCC_CSR register for the reset source, but it is setting RCC_CSR_PORRSTF flag for both cases. How do I differentiate between the two interrupts? And from what I have worked with standby mode, I have an impression that the controller neither resumes the normal execution nor calls the interrupt service routine but resets on wake up from standby mode (please correct me if I am wrong).
2. During a pin wake up interrupt, I need to write a byte of information on a non-volatile memory and go back to standby mode (nothing else to do). While waking up via clock interrupt I should be able to access the written data and do accordingly. I have come across backup SRAM (function to be used: HAL_PWREx_EnableBkUpReg()). Am I on the right path? Is there any other setting to be done inorder to write this byte of information into backup SRAM? Or is there another way to tackle the issue (other than EEPROM)?
I have the standby code and pin wake up code working as per my requirements, but stuck with these issues.
Thank You,
Allan Tom Mathew.
#stm32 #stm32f767 #reset-source #wakeup-pin #backup-sram #reset #stm32f72017-11-30 03:04 PM
And from what I have worked with standby mode, I have an impression that the controller neither resumes the normal execution nor calls the interrupt service routine but resets on wake up from standby mode (please correct me if I am wrong).
IMO, the Exiting Standby mode subchapter of PWR chapter of RM is very clear in this:
After waking up from Standby mode, program execution restarts in the same way as after a
Reset (boot pin sampling, vector reset is fetched, etc.).---
How do I differentiate between the two interrupts?
(Apart from that they are not *interrupts* as said above), try checking the respective wakeup flag in PWR_CSR2, and/or the respective flag in RTC_ISR.
---
I need to write a byte of information on a non-volatile memory
You don't need to use the backup SRAM (thus burn current from battery) for one byte once you use RTC anyway, check out the RTC Backup Registers RTC_BKPxR.
I don't Cube.
JW
2017-11-30 06:03 PM
The Backup RAM does provide 4K of space with the processors normal address space, you can memcpy() in and out, or place structures in there. I would perhaps use pointers and have a structure with a signature and checksum to confirm integrity.
2017-12-01 05:56 AM
Thank you
Waclawek.Jan
andTurvey.Clive.002
.After waking up from Standby mode, program execution restarts in the same way as after a
Reset (boot pin sampling, vector reset is fetched, etc.).
Thank you for the exact wordings... this is a programmer's strength.
(Apart from that they are not *interrupts* as said above)
Yup they are not interrupts but I didn't know what to call them.
try checking the respective wakeup flag in PWR_CSR2, and/or the respective flag in RTC_ISR.
This was exactly what I was looking for. And I could implement it in my code successfully too. For some odd reason I was looking for a PWRfunctionality in RTC registers. My bad.
You don't need to use the backup SRAM (thus burn current from battery) for one byte once you use RTC anyway, check out the RTC Backup Registers RTC_BKPxR.
Thank you for the suggestion. I tried using
RTC_BKPxR
register. When the micro controller is working in run mode, a normal read-write operation onRTC_BKPxR works fine (I'm able to get the data that I have written). Butthe byte that Iwrite during a PC1 (pin) wakeup isnot available during a RTC wakeup. I tried the code with and without switching on the backup regulator (PWR_CSR1_BRE) but in vain. Just to make sure that I'm not missing anything, I have connected Vdd to Vbat too.
Am I missing something obvious here? Is there anything extra that I should be doing to access RTC backup register?
Thank You.
Allan Tom Mathew.