This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to read flash in C - c8051F020

Hi, the problem is that the compiler uses MOVX instead of MOVC when I'm reading the rom, of course it doesn't work. There's no problem to write the flash. I don't want to add an assembly routine.
Is there any other solution?
I'm using Silabs C8051F020.

Thanks.

Parents
  • Write in flash only clear bits, so you have to initialize the code variable with 0xff, or erase the entire block before write.

    unsigned char xdata variable[2]={0x46,0x11};
    unsigned char xdata variable_2[2]={0};
    unsigned char code string_1[2]={0xff,0xff};

    write_flash(string_1,variable); //writing to flash

    variable_2[0] = string_1[0]; //reading from flash
    variable_2[1] = string_1[1];

    Thank you.

Reply
  • Write in flash only clear bits, so you have to initialize the code variable with 0xff, or erase the entire block before write.

    unsigned char xdata variable[2]={0x46,0x11};
    unsigned char xdata variable_2[2]={0};
    unsigned char code string_1[2]={0xff,0xff};

    write_flash(string_1,variable); //writing to flash

    variable_2[0] = string_1[0]; //reading from flash
    variable_2[1] = string_1[1];

    Thank you.

Children