I'm developping an application using LV32MX v6 with PIC32MX460F512L with MikroPascal Pro for PIC32.
I need to save / retrieve data from internal program flash. After having reading infos from Microchip doc, I started to write some code to do the job using the provided Flash library, without success... Then I decided to try the example that came with compiler, Flash.mpp32, slightly modified to see activity on RA3 led:
Code: Select all
{*
* Project name:
Flash (Flash writing example)
* Copyright:
(c) Mikroelektronika, 2012.
* Revision History:
20110105:
- initial release;
* Description:
This is a simple demonstration how to use to PIC32's internal flash memory to
store data. The data is being written starting from the given location;
then, the same locations are read and the data is displayed on PORTB and PORTD.
* Test configuration:
MCU: P32MX460F512L
http://ww1.microchip.com/downloads/en/DeviceDoc/61143G.pdf
Dev.Board: EasyPIC Fusion v7
http://www.mikroe.com/easypic-fusion/
Oscillator: XT PLL 8, 80.000MHz
Ext. Modules: None.
SW: mikroPascal PRO for PIC32
http://www.mikroe.com/mikropascal/pic32/
* NOTES:
- Turn ON PORTB and PORTD LEDS at SW15 (board specific).
*}
program Flash;
var rowbuff : array[128] of dword;
var i, Address : dword;
var ptr : ^dword;
begin
AD1PCFG := 0xFFFF;
TRISA := 0;
LATA := 0;
LATB := 0;
TRISB := 0;
LATD := 0;
TRISD := 0;
Address := 0x9d001000;
PORTAINV := 0x08;
for i := 0 to 127 do
rowbuff[i] := i + (i shl 16);
Flash_Write_Row(Address,@rowbuff); // write one row
PORTAINV := 0x08;
ptr := Address;
for i := 0 to 127 do
begin
LATB := ptr^;
LATD := ptr^ shr 16;
Inc(ptr);
PORTAINV := 0x08;
Delay_ms(150);
end;
Delay_ms(1000);
Flash_Erase_Page(Address); // erase page
Flash_Write_Word(Address, 0xAAAAAAAA);// write one word
ptr := Address;
LATB := ptr^;
LATD := ptr^ shr 16;
end.
And I have the same problem, I'm unable to see the data written with the Flash_Write_Row() procedure on PORT A&D LEDs. But the last part of the program, which is using Flash_Write_Word() is working, I can see the 0xAAAAAAAA displayed by the leds.
I've already checked in the configuration of the project if writing on program flash is enabled.
I can't find any clue in order to see if it's a writing or reading problem ...
So any help will be highly appreciated.
Thx!