Writing to Flash on C8051f350

Hello,

I have some problem when I try to write to Flash memory.

I read AN201 "WRITING TO FLASH FROM FIRMWARE" and I use write functions for F350 (page 100).

There is no problem with a light program.
But now I try to integrate these functions on a large program. When I look at memory, any data has been written.

In AN20 (page 3), I found this : "Be cautious when using the 'Large' and 'Compact' memory models, which target xdata and pdata spaces for user variables, both of which generate MOVX write opcodes."
Indeed, my first program use small memory model (no pb) and my last program use large one.

Is there a solution to write to flash memory with a large program ?

Parents
  • "Is there a solution to write to flash memory with a large program ?"

    I'm not familiar with your particular derivative, but I'm assuming that the procedure to write to the flash is something like:

    1) Map the flash into xdata space
    2) Write to flash
    3) Map the flash back out of xdata space

    If an interrupt occurs during this sequence and the associated ISR accesses the xdata memory space you are in trouble. One solution is to disable interrupts before step (1) and reenable them after step (3).

Reply
  • "Is there a solution to write to flash memory with a large program ?"

    I'm not familiar with your particular derivative, but I'm assuming that the procedure to write to the flash is something like:

    1) Map the flash into xdata space
    2) Write to flash
    3) Map the flash back out of xdata space

    If an interrupt occurs during this sequence and the associated ISR accesses the xdata memory space you are in trouble. One solution is to disable interrupts before step (1) and reenable them after step (3).

Children
More questions in this forum