STM32H7 Run* mode before configuring PWR_CR3
We are using the STM32H745 in one of our projects. We are using "LDO supply" mode (configuration 1 in Fig. 22 from RM0399 v3). Section 7.4 of RM0399 describes the power-up sequence, including a Run* mode where application code starts executing but is not allowed to write to RAM until one of the supply configurations has been selected by writing the write-once byte in PWR_CR3. The manual notes that RAM writes in Run* mode are forbidden:
- Section 7.4.1:
- 4. Once the oscillator is stable, the system is initialized: Flash memory and option bytes are loaded and the CPU starts in limited run mode (Run*).
- 5. The software shall then initialize the system including supply configuration programming in PWR control register 3 (PWR_CR3). Once the supply configuration has been configured, the ACTVOSRDY bit in PWR control status register 1 (PWR_CSR1) shall be checked to guarantee valid voltage levels:
- a) As long as ACTVOSRDY indicates that voltage levels are invalid, the system is in Run* mode, write accesses to the RAMs are not permitted and VOS shall not be changed.
- b) Once ACTVOSRDY indicates that voltage levels are valid, the system is in normal Run mode, write accesses to RAMs are allowed and VOS can be changed.
- Fig. 23: "In Run* mode, write operations to RAM are not allowed."
- Fig. 24: "In Run* mode, write operations to RAM are not allowed."
There may be other references; it is difficult to search for "Run*" in my PDF viewer since it ignores the star in the search box.
In our project, I had not been taking any special measures to avoid writes to RAM before setting the supply configuration. Looking at the STM32CubeH7 sample code I see that no special care is taken there either; global variables are accessed, non-inlined functions appear to be called requiring stack frames, etc., all before HAL_PWREx_ConfigSupply() is called to finally select a supply configuration.
Is the RM just flat-out wrong on this regard? Or is there are subset of RAMs that are safe to access from the default supply configuration before writing to PWR_CR3? Maybe by "RAM" they mean external RAMs and not SRAMs? Or is both my code (which seems to have been working fine for over a year) and the STM32CubeH7 code wrong and we're both just lucky?
I just did the work of updating my code to configure PWR_CR3 before any RAM accesses occur (including before doing any pushes to the stack), but am wondering if that was really necessary at all and if perhaps the RM or example code could be updated for consistency with one another.
Thanks,
TG