Hello,
I need assistance to write data into program flash memory of p18f67k40.
I am able to read data from pfm using FLASH_Read() under FLASH library.
But when I try to write data into pfm, its not making any change in the pfm.
But when I read after calling FLASH_Erase() on some address, I get FF on entire row.
The IDE that I use is MikroC Pro.
Looking forward for some advices.
Thankyou.
Read/Write program flash memory of PIC18F67K40
- IvanJeremic
- mikroElektronika team
- Posts: 316
- Joined: 05 Sep 2022 14:32
Re: Read/Write program flash memory of PIC18F67K40
Hi,
Make sure to erase to use FLASH Erase before writing anything to it.
You can find the example on how to use FLASH Write below:
Regards,
Ivan.
Make sure to erase to use FLASH Erase before writing anything to it.
You can find the example on how to use FLASH Write below:
Code: Select all
unsigned short toWrite[64];
...
// initialize array:
for (i = 0; i < 64; i++)
toWrite[i] = i;
// write contents of the array to the address 0x0D00:
FLASH_Write_64(0x0D00, toWrite);
Ivan.
Re: Read/Write program flash memory of PIC18F67K40
Hello Ivan,
Thankyou for your answer.
But there are few things that I want to say,
1) PIC18F67K40 on MikroC Pro v7.6.0 have only functions like FLASH_Read/Write/Erase(). It does not have function like FLASH_Write_64().
2) The address parameter in FLASH_Read/Write/Erase() has type unsigned which has size 2 bytes according to MikroC Pro's documentation. Then how can we work with locations
of greater than 2 Bytes ? According to datasheet this mcu has 128KB of program flash memory.
3) With the functions FLASH_Read/Write/Erase(), Im able to work on memory locations within 2 Bytes of range.
Looking forward to hearing from you.
Regards.
Thankyou for your answer.
But there are few things that I want to say,
1) PIC18F67K40 on MikroC Pro v7.6.0 have only functions like FLASH_Read/Write/Erase(). It does not have function like FLASH_Write_64().
2) The address parameter in FLASH_Read/Write/Erase() has type unsigned which has size 2 bytes according to MikroC Pro's documentation. Then how can we work with locations
of greater than 2 Bytes ? According to datasheet this mcu has 128KB of program flash memory.
3) With the functions FLASH_Read/Write/Erase(), Im able to work on memory locations within 2 Bytes of range.
Looking forward to hearing from you.
Regards.
- IvanJeremic
- mikroElektronika team
- Posts: 316
- Joined: 05 Sep 2022 14:32
Re: Read/Write program flash memory of PIC18F67K40
Hi,
You can still use the FLASH_Write function like the FLASH_Write_64.
You should be able to use the memory of the MCU with the available FLASH library. Regards,
Ivan.
You can still use the FLASH_Write function like the FLASH_Write_64.
You should be able to use the memory of the MCU with the available FLASH library. Regards,
Ivan.
Re: Read/Write program flash memory of PIC18F67K40
Hi Ivan,
Thanks for this.
Just to make sure, so
1) FLASH_Erase() will erase 64(words) * 2(word size) = 128 locations (or bytes) from given address ?
2) Similarly FLASH_Write() will write 128 locations (or bytes) from the given address ?
3) But FLASH_Read() will read 1 byte from given address ?
Looking forward.
Regards.
Thanks for this.
Just to make sure, so
1) FLASH_Erase() will erase 64(words) * 2(word size) = 128 locations (or bytes) from given address ?
2) Similarly FLASH_Write() will write 128 locations (or bytes) from the given address ?
3) But FLASH_Read() will read 1 byte from given address ?
Looking forward.
Regards.