AnsweredAssumed Answered

Writing to Flash on a PN7462

Question asked by Richard Boud on Feb 9, 2019

I am trying to use the PN7462 API to read and write from flash memory. I am not sure of the syntax. Has anyone got any examples of this working? My effort is below:


PH_USER_ASSERT(phhalFlash_Init(false, true) == PH_ERR_SUCCESS);
uint8_t WriteBuffer[4] = {0x02, 0x03, 0x04, 0x05};
uint8_t ReadBuffer[4] = {0x00, 0x00, 0x00, 0x00};
uint8_t *WriteAddress = PHHAL_FLASH_USER_PAGE_START; 
phStatus_t FlashErrorStatus;
uint32_t WordLength = 4;

printf("Flash Start Address = %d\n", WriteAddress);
printf("Flash Read Address = %d\n", ReadAddress);
printf("Read = %04x %04x %04x %04x\n", ReadBuffer[0], ReadBuffer[1], ReadBuffer[2], ReadBuffer[3]);
FlashErrorStatus = phhalFlash_WritePage(WriteAddress, WriteBuffer);
FlashErrorStatus = phhalFlash_ReadBuffer(ReadBuffer, ReadAddress, WordLength);
printf("Write = %04x %04x %04x %04x\n", WriteBuffer[0], WriteBuffer[1], WriteBuffer[2], WriteBuffer[3]);
printf("Read = %04x %04x %04x %04x\n", ReadBuffer[0], ReadBuffer[1], ReadBuffer[2], ReadBuffer[3]);


If I run this it will, I think, overwrite part of my program that is located elsewhere on the Flash leaving the board unrecoverable. However, I am not sure that is what is happening.