Clearing StandbyRam

How do I initialize stand ram? I want to clear the standby ram (Version 6.0, 3068 bytes) to zeroes.

You can use memset(ptr, 0, size)

1 Like

Thank you ScruffR. I’m somewhat new to Particle Electron programming but it didn’t work for me.

Here is what I did:

memset(start_adr, 0, 3036) // where start_adr = 32

I received the following error: invalid conversion from ‘int’ to ‘void*’ [-fpermissive]

Am I not setting the start_adr correctly?

Thanks in advance

memset() needs a pointer to work on, but that’s not specific to Particle but standard C.
So you should write this instead

  memset((void*)start_adr, 0, 3036);

But I doubt that the actual address of backup RAM is 32 - should rather acquire the base address from an existing retained variable.

Another option to clear the area might be not to call STARTUP(System.enableFeature(FEATURE_RETAINED_MEMORY)); after a reset, then reset again an then enable retained vars again.