Copy RAM to flash strange error code

I am trying to write some data to Flash. While Prepare sector (cmd 50) and Erase sector (cmd 52) returns CMD_SUCCESS, I am having a hard time figuring out what should I send as a parameters to command 51.

  uint8_t data[] = {0x12, 0x88};
  uint8_t *dataPtr = &data[0];
  command[0] = 51;
  command[1] = a_dest; //destination address 0x1ff0
  command[2] = (uint32_t)dataPtr;
  command[3] = 2;
  command[4] = 48000000UL/1000; //frequency in kHz
  iap_entry(command, output);


This command returns output[0] == 0x0D, which doesnt even exist in datasheet as an error code...

While datasheet says that param 3 needs to be 256/512/1024 bytes long, I am not sure what should I do if I only want to update 2 bytes? Do I need first to read 256 bytes from (0x1ff2-256) and then change last two bytes in buffer and send that as a param2 ?

Microcontroller is LPC11C14.

Thanks

Parents
  • Yes, you need to copy out old flash data into the RAM buffer and patch it, so you can do a large copy from RAM to flash. The flash doesn't support any 2-byte updates because the flash data is based on sectors and the sectors are using ECC error correction forcing the size of the copy operations.

Reply
  • Yes, you need to copy out old flash data into the RAM buffer and patch it, so you can do a large copy from RAM to flash. The flash doesn't support any 2-byte updates because the flash data is based on sectors and the sectors are using ECC error correction forcing the size of the copy operations.

Children
More questions in this forum