??? 06/20/05 16:50 Read: times |
#95379 - for those of you who need this Responding to: ???'s previous message |
Some chips have "straight forward" write capabilities re writing flash. So, if you need that, use such a chip.
here is an example for using the top 64k (of 128) of a SILabs f126 for permanent data storage (erased sector is a prerequisite): void WriteFlash (U8 xdata * WFSaddr, U8 WFCdata) { U8 WFCintsav; WFCintsav = SG_IE; SG_IE = 0; SG_SFRPAGE = 0x0f; SF_CCH0CN &= 0xfe; // single byte write SG_SFRPAGE = 0; if (WFSaddr > 0x7fff) { SG_PSBANK = 0x30; } else { SG_PSBANK = 0x20; WFSaddr += 0x8000 ; } S0_FLSCL |= 0x01 ; // flash write S0_PSCTL |= 0x01 ; // movx to flash *WFSaddr = WFCdata ; //write the byte S0_PSCTL &= 0xfe ; // restore S0_FLSCL &= 0xfe ; // restore SG_PSBANK = 0x10 ; SG_IE = WFCintsav; } Erik |