Edit flash/EEPROM in MPLABX

Status
Not open for further replies.

Pommie

Well-Known Member
Most Helpful Member
I'm trying to edit the flash memory in a pic16F18854 - flash goes from zero to 0fff (4k). I've reserved the last 1k (0c00-0fff) by setting the memory model (in linker) to exclude the area,

I've also told pickit4 to preserve this area by doing,

I can change location 0c00 but there is no way to write it to the device.

I can read the device memory but if I then try to edit the flash it tells me,

I have done multiple "Debug Builds" to no avail.

Am I missing something? Does anyone know how to do this?

Anyone wondering the project is called read_vdd.

Mike.
 
Turn off the restrictions for one build, and add an include file with the data you want to store??

eg. This is how I save to flash in one of my projects:

Code:
#ORG 0x00020000
#include "w:\Projects\!!!includes\Images\image_header.txt"
#include "w:\Projects\!!!includes\Images\jrw_logo_16.txt"
...

The header starts with
Code:
ROM BYTE bmp_images[] = {
to define the storage as in flash.

Or, use the MCUs write to flash instruction and have your program initialise the area if the correct data does not exist - eg. use "magic numbers" before and after to validate it, and/or add a CRC check.
 
#org isn't valid in XC8. Just spent over an hour trying to find out how you store data in flash. Many people have asked the question but no answer.

Mike.
 
How about making the data to be stored CONST so it's allocated to flash, then getting that address from the linker map to use for non-writing versions?

Or, as I said earlier, add a routine to initialise the flash data area if it does not exist?

Apparently XC8 does not have native routines to write program memory, but it's possible by adding assembler routines - some outline examples here:
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…