I am using the Renesas 65n1 Flash FIT module to program the code flash on the R6519AxFP.
I can program a page of 128 bytes after an erasure.
I tryed with "HEJ", keeping all the other bytes as 0xFF. This works.
The i tried to program the same page of 128 bytes as
"HEJ MOR" but i get a FLASH_ERR_FAILURE error.
I can however write "Hello World! I like Cake!" to the page if i erase the entire block (32 KiB) first and then write to it.
I can also write to other 128 byte pages without erasing, but i cannot rewrite the same page.
Here is my test code:
char test; memset(test,0xFF,256); test = hal_flash_erase(0xFFFE8000, 1); //Erase hal_flash_read(test, 0xFFFE8080, 128); //Check data = ok test = 'H'; test = 'E'; test = 'J'; test = hal_flash_write(test, 0xFFFE8080, 128); //Works as intended hal_flash_read(test, 0xFFFE8000, 256); test = 'H'; test = 'E'; test = 'J'; test = ' '; test = 'M'; test = 'O'; test = 'R'; test = hal_flash_write(test, 0xFFFE8080, 128); //Gives error FLASH_ERR_FAILURE hal_flash_read(test, 0xFFFE8000, 256); test = 'H'; test = 'E'; test = 'J'; test = hal_flash_write(test, 0xFFFE8000, 128); //Works hal_flash_read(test, 0xFFFE8000, 256);
That's specification. Memory cells must only be programmed once. Before reprogramming it must be erased. Reprogramming without erase would put increased stress on the memory cell and is prohibited.
In reply to FrankL:
In reply to Worker101:
I'm also curious about where this is in the manual, if you're saying two consecutive writes to the same page of RX65* code flash without an intervening erase will return error. I seem to be running into the same issue. I've written to a page of code flash, keeping one sequence of bytes as 0xFF so I can set them later, but I get the PGMERR bit in flash every time I try to do a 2nd write. If this is true, it's contrary to the behavior of most flash memory I've worked with. Is the code flash setting a private bit in the block indicating it's been written to and, if set when another write occurs, fails the write? Thanks, Anthony
In reply to AnthonyJenkins:
It is stated on page 2599 in the datasheet for the RX65* (3) Prohibition of Additional Programming Programming a given area of the code flash memory or data flash memory twice is not possible. To program the code flash memory or data flash memory where has been programed, erase the target area. Programming can be added to the option-setting memory. For details, refer to Flash Memory User’s Manual: Hardware Interface.
Thanks Worker101! This morning I finally got my bits of user code moved into the RAM segment that r_flash_rx uses for destructive code flash operations and I can safely rewrite code flash.