Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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,
linker.png

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

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,
debug.png

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.
 

rjenkinsgb

Well-Known Member
Most Helpful Member
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.
 

Pommie

Well-Known Member
Most Helpful Member
#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.
 

rjenkinsgb

Well-Known Member
Most Helpful Member
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.

Latest threads

New Articles From Microcontroller Tips

Top