#3617 - wtuck - Sat Mar 01, 2003 10:43 pm
Hi,
I'm trying to modify the flash by downloading some data via the serial port. I have been able to get the device ID and Type from the flash and even program the some of the flash. Eraseing it is my real problem I've tried a few variations of code and can erase a block but my program never returns from the function placed in ram. (Note: my other functions like reading the device id and type, do return). My code is below any ideas?
I'm trying to modify the flash by downloading some data via the serial port. I have been able to get the device ID and Type from the flash and even program the some of the flash. Eraseing it is my real problem I've tried a few variations of code and can erase a block but my program never returns from the function placed in ram. (Note: my other functions like reading the device id and type, do return). My code is below any ideas?
Code: |
#define CODE_IN_IWRAM __attribute__ ((section (".iwram"), long_call))
CODE_IN_IWRAM void WriteFlash (u32 addr, u16 data) { *(vu16 *)addr = data; } CODE_IN_IWRAM u16 ReadFlash (u32 addr) { return(*(vu16 *)addr); } // *************************************************************** void test_BlockErase(void) { u8 status; flash_BlockErase(2, &status); } // *************************************************************** // * flash_BlockErase // *************************************************************** CODE_IN_IWRAM void flash_BlockErase(u8 bank, u8 * status) { u16 Timeout; u8 done; WriteFlash(0x8020000, _CMD_STATUS_CLEAR); //0x50 *status = flash_Status(); WriteFlash(0x8020000, _CMD_BLK_ERASE); //0x20 WriteFlash(0x8020000, _CMD_BLK_ERASE_CONF); //0xDO *status = flash_Status(); done = 0; Timeout = 0xFFFF; while ((done == 0) && (Timeout != 0)) { WriteFlash(0x8020000, _CMD_STATUS); //0x70 *status = ReadFlash(0x8020000); done = (*status & 0x80); Timeout--; } // end while WriteFlash(0x8020000, _CMD_READ); //0xFF WriteFlash(0x8020000, _CMD_READ); //0xFF return; } |