Reply
Posts: 13
Registered: ‎04-19-2016

pearl gecko write to user page

Hello, 

 

I am trying to write to the user data page on a Pearl Gecko.  The code below first erases the page, then writes a value to the first word and reads it back.  It appears to work, but then subsequent power cycles read back 0xffffffff.  Not sure what I could be missing.

 

uint32_t *userdata = (uint32_t *)USERDATA_BASE;
MSC_Init(); printfc(PR_YELLOW, "USERDATA = 0x%08lx\n", *(uint32_t *)userdata); printf("ERASE: %d\n", MSC_ErasePage( (uint32_t *)userdata )); printfc(PR_YELLOW, "USERDATA = 0x%08lx\n", *(uint32_t *)userdata); uint32_t data = 0x12345678; printf("WRITE = %d\n", MSC_WriteWordFast( userdata, (void *)&data, sizeof(data) )); printfc(PR_YELLOW, "USERDATA = 0x%08lx\n", *(uint32_t *)userdata); MSC_Deinit();

 

Posts: 13
Registered: ‎04-19-2016

Re: pearl gecko write to user page

Update:

the value written the the user page retains its value across power cycles if the ULW is set to 0 prior to MSC_Deinit().  Don't recall seeing that in documentation or example code anywhere.  It is still not clear then how to update the value once it has been written, since the only way I can reset the ULW is to perform a device erase with jlink.

 

Highlighted
Posts: 270
Registered: ‎03-03-2015

Re: pearl gecko write to user page

Hi rrogers,

 

I was able to run this code by pasting it into an empty Pearl Gecko project, the ULW on my kit (SLSTK3401A) is erased (set to 1).  Does it do this after a device erase?  Are you using an STK or a custom board?

 

Regards,

Joe

Posts: 13
Registered: ‎04-19-2016

Re: pearl gecko write to user page

Yes, after a device erase, the ULW is set to all f's.  The problem is that if I use MSC functions to write data to the user page without setting ULW to 0, the custom data that was written to the user page is wiped on subsequent power cycles.  I don't understand what could be causing that.  I'm using a custom board.