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
  • Thank you, I did not know/remember the code type.
    After a little fight I made it work.
    The routine, if somebody needs it.

    unsigned char read_flash(unsigned char code *source)
    { bit Ea_ant;

    unsigned char var_read = 0x01;

    Ea_ant = EA;

    EA = 0;

    FLSCL |= 0x01; //enable write/read flash

    PSCTL |= 0x01; //movx target to flash

    var_read = *source;

    PSCTL &= ~0x01;

    EA = Ea_ant;

    return var_read;
    }

Reply
  • Thank you, I did not know/remember the code type.
    After a little fight I made it work.
    The routine, if somebody needs it.

    unsigned char read_flash(unsigned char code *source)
    { bit Ea_ant;

    unsigned char var_read = 0x01;

    Ea_ant = EA;

    EA = 0;

    FLSCL |= 0x01; //enable write/read flash

    PSCTL |= 0x01; //movx target to flash

    var_read = *source;

    PSCTL &= ~0x01;

    EA = Ea_ant;

    return var_read;
    }

Children