Dear All,
I've been trying to use the General Purpose Registers in the System Reset Controller to record some custom information in my application, then cause a software reset and read this information back in the bootloader. Such information would be the cause of the reset, a boot counter, etc. I cause the reset by calling the macro NVIC_SystemReset().
The SDK provides functions to read & write to these registers:
SRC_SetGeneralPurposeRegister (SRC_Type *base, uint32_t index)
SRC_GetGeneralPurposeRegister (SRC_Type *base, uint32_t index, uint32_t value)
which I've been using as such:
SRC_SetGeneralPurposeRegister(SRC, 0, 1) // write 1 to reg 0
SRC_SetGeneralPurposeRegister(SRC, 1, 5) // write 5 to reg 1
but I find when I read the values back after returning to the Bootloader, the values are garbled and not what I set them to. I thought the whole idea was these registers remain unchanged across a reset.
There doesn't seem to be any particular initialisation mentioned by the SDK documentation that needs to be done prior to using these registers and unfortunately there are no examples in the SDK I could find.
Any idea why it doesn't work?
For a workaround, I tried using SRC_GetResetStatusFlags() to give a warm/cold start indication at least, but this always seems to indicate warm start (i.e. a deliberate SW Reset occurred), but I wonder if this will always be the cause when using a debugger (Segger)?
Any other ideas for application -> bootloader handshaking would be welcome, if this is not the right approach.
Regards, Damon