Thank you for sharing this information. I am very interested in completing a small project to write and read from flash.mytekcontrols wrote:For those that are following this, Ben just sent me some alternative C Code for Reading and Writing to the Flash Memory area on the PIC. Apparently there is a problem with getting the original examples to compile in FlowCode.
Here are the new versions:FCV_TEMP = byte to be written into Flash memory, or value that was read from Flash memory (from FlowCode this would be variable "TEMP").Code: Select all
/* Read from Flash Memory */ volatile char* register_ptr = (char*)FCV_ADDR; FCV_TEMP = *register_ptr; /* Write to Flash Memory */ volatile char* register_ptr = (char*)FCV_ADDR; *register_ptr = FCV_TEMP;
FCV_ADDR = 16-bit integer for Flash memory address where byte will be written to, or read from (from FlowCode this would be variable "ADDR").
This code appears to compile properly, although I have yet to actually try to use it with real hardware.
I have created a small test program. Unfortunately the the variable which is suppose to write to flash are volatile( in line with what mytekcontrols was saying), so contents are lost when power is re-applied. What I am trying to acheive is Read from ADC1 store ADC1 variable. Finaly read the stored ADC1 after power is removed and restablished.
I am trying to figure out reason, but any help is greatly appreciated as I am not getting very far.
Thank you in advance.