hmm this world is so mean...
Here is the code:
Code: Select all
program Flash
Const ConfigAddress as longword[4096] = (0) org $9D001000 'reserve 1 entire memo page to be written.
dim ptr as ^longword
dim i as longword
main:
AD1PCFG = 0xFFFF
LATB = 0
TRISB = 0
LATD = 0
TRISD = 0
i = ConfigAddress[0] 'just in case if linker try to optmize the code removing the placeholder
Flash_Erase_Page(@ConfigAddress)
Flash_Write_Word(@ConfigAddress[0],0x0000AAAA)
ptr = @ConfigAddress
LATB = ptr^
end.
Beautiful, neat and simple.
The code above writes the value 0x0000AAAA to the flash and then read the flash and output the value in port B.
It works!
BUT... it
stops working if you remove the line
then the value on port B is 0x00000000.
Why