Why does power management corrupt SPI registers on STM32WLE5?
When attempting to add an accelerometer to the LoRaWAN_End_Node program, on the SPI1 interface, I find that it works (in polled mode) until the board sleeps and is woken with an interrupt. Then the SPI1 Control Register 1 and Control Register 2 are changed (so the accelerometer can't be accessed).
I have spent ages chasing this, as the exact nature of the corruption changes as my code changes. Because the corruption showed as soon as an interrupt happens (GPIO (button press), timer, subGHz radio) I assumed the problem was related to interrupts. Then I figured the corruption might be due to activity just before the interrupt, as the chip is put in a low power state. Sure enough, changing LOW_POWER_DISABLE from 0 to 1 in sys_conf.h makes the problem vanish.
Note the corruption varies and sometimes there is no corruption: CR1 can change from 0x035f to 0x0040 or to 0x0000 and CR2 can change from 0x1700 to 0x0700. The values are the same for a given build. It is almost as though it is code-position-dependent.
Can someone please tell me why the SPI interface is broken as I describe, and what I can do about it.
I see that AN5406 includes "7.3 Low-power functions" which I assume is relevant, but I would appreciate more specific guidance.
Will this problem exist with other peripherals, as well as the SPI?