Marlon
Don't be mislead by the address of the program once field. It is not a memory mapped address such as program Flash.
The K60 has 8 "record Indexes" which are 8 byte phrases than can be written or read. This gives 8 x 8 bytes (64 bytes) in these indexes.
When reading or writing, the FCMD_PROGRAM_ONCE or FCMD_READ_ONCE commands are issued to the Flash controller, along with the record index in question and the flash controller either programs the record or returns its content.
The program once area cannot be addresses by a physical address so is not readable by using a pointer.
You can get program once interface code from the uTasker project which gives the following general program once interface:
extern int fnProgramOnce(int iCommand, unsigned long *ptrBuffer, unsigned char ucBlockNumber, unsigned char ucLength);
It supports programming and retrieving the MAC address from this area using the routines (showing how the interface is used):
Retrieval:
static void fnGetUserMAC(void)
{
unsigned long ulTestBuffer[2]; // the MAC address is saved in two long words
fnProgramOnce(PROGRAM_ONCE_READ, ulTestBuffer, 0, 2); // read 2 long words from the start of the program-once area
if (uMemcmp(ulTestBuffer, cucBroadcast, MAC_LENGTH) != 0) { // if programmed
uMemcpy(network[DEFAULT_NETWORK].ucOurMAC, ulTestBuffer, MAC_LENGTH); // use the stored value as MAC address
}
}Programming:
unsigned long ulTestBuffer[2];
ulTestBuffer[1] = 0xffffffff;
uMemcpy(ulTestBuffer, temp_pars->temp_network[DEFAULT_NETWORK].ucOurMAC, MAC_LENGTH); // retrieve first MAC address from storage
fnProgramOnce(PROGRAM_ONCE_WRITE, ulTestBuffer, 0, 2); // save to the first 2 long words in the program once area
Note that all operations use an 8 byte phrase (buffer) and unused bytes are set to 0xff. The MAC thus occupies a single phrase (organised as 2 long words in the passing buffer). In the uTasker projet the first phrase is used as MAC address as convention when the option is enabled.
The uTasker Kinetis simulator also simulates the Program Once Memory (as well as all other Flash operation) to allow experimenting with code to ensure correct usage before moving to the HW (where any mistakes can't be deleted).
Regards
Mark