cancel
Showing results for 
Search instead for 
Did you mean: 

Reset source and backup SRAM in STM32F7

allantommathew
Associate II
Posted on November 30, 2017 at 12:51

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 #stm32f7
3 REPLIES 3
Posted on December 01, 2017 at 00:04

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

Posted on December 01, 2017 at 03:03

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.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
allantommathew
Associate II
Posted on December 01, 2017 at 14:56

Thank you

Waclawek.Jan

and

Turvey.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 on

RTC_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.