This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

INVALID MEMORY ACCESS when writing to NRF_POWER->GPREGRET

I am trying to write to NRF_POWER->GPREGRET to store some variables that should be retained through a software reset.

I am running SD 5, SDK 14 and using GCC to compile.

When I try to write to the register, i.e:

NRF_POWER->GPREGRET = 0x01

The program is halted by the error:

<error> app: SOFTDEVICE: INVALID MEMORY ACCESS

Printed out over UART.

Any thoughts on what is causing this error or how it could be solved?

Parents
  • When using the SoftDevice I would recommend using the formal interface. With no SoftDevice installed your code would work fine. Worth a try :-)

    uint32_t resultCode = sd_power_gpregret_set(0, 0x01);
    
    // For specification see here:
    
    /**@brief Set bits in the general purpose retention registers (NRF_POWER->GPREGRET*).
     *
     * @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2.
     * @param[in] gpregret_msk Bits to be set in the GPREGRET register.
     *
     * @retval ::NRF_SUCCESS
     */
    SVCALL(SD_POWER_GPREGRET_SET, uint32_t, sd_power_gpregret_set(uint32_t gpregret_id, uint32_t gpregret_msk));
    

Reply
  • When using the SoftDevice I would recommend using the formal interface. With no SoftDevice installed your code would work fine. Worth a try :-)

    uint32_t resultCode = sd_power_gpregret_set(0, 0x01);
    
    // For specification see here:
    
    /**@brief Set bits in the general purpose retention registers (NRF_POWER->GPREGRET*).
     *
     * @param[in] gpregret_id 0 for GPREGRET, 1 for GPREGRET2.
     * @param[in] gpregret_msk Bits to be set in the GPREGRET register.
     *
     * @retval ::NRF_SUCCESS
     */
    SVCALL(SD_POWER_GPREGRET_SET, uint32_t, sd_power_gpregret_set(uint32_t gpregret_id, uint32_t gpregret_msk));
    

Children
Related