Flash Read/Write in RL78/G15

Hello Team,

I am trying to write a data in Flash Memory of RL78/G15 (Memory address 0x9000 to .... ).
The correct approach would be to enable the flash memory first and then write. Then will read the location to confirm the written data. And then disable the Flash memory again to avoid any unnecessary writing.
Please correct me if I am wrong.

Now the problem I am facing is I am not able to write the data , nor verify it.
Please suggest, open to both approaches - using APIs or baremetal coding.

I tried this but not getting proper results. I have tried a sample code & APIs available on E2 studio.

#include "r_smc_entry.h"

//#include "sample_control_data_flash.h"

#include "../src/DF_sample/common/include/sample_control_data_flash.h"

int main (void);

extern int sample_dataflash_main(void);

uint8_t t ;

uint8_t tmp[1] = {"B"};

uint8_t read_from_data_flash(uint16_t address)

{

// Access the data flash at the given address

uint8_t data = *(volatile uint8_t*)address; // Dereferencing the memory address directly

return data;

}

int main(void)

{

EI();

sample_dataflash_main();

Sample_DataFlashControl(0x9000, 1, &tmp[0]);

t = read_from_data_flash(9000);

while(1)

{

}

}

Happy New Year All!!!!!

Parents Reply Children
No Data