2008-01-05 04:46 AM
2008-01-05 04:46 AM
I have a following problem. There is a program which located in to 0xE000 address. The given program accepts the new program on ASC0 and writes down it to 0x0F0000 address. Then he should write down it in IFLASH to 0x0000 address.
The code for erasing IFLASH looks as follows: ... FCR0H = 0x0080; //Set the Select Module bit to work on the IFlash FCR0H = FCR0H | 0x0800; //Set the Sector Erase Bit FCR1L = 0x0001; //Set the specified Bank Status Bit FCR1H = 0x0000; FCR0H = FCR0H | 0x8000; //Set the Write Mode Start Bit //some delay if (! (FCR0L & 0x0010)) { if (! (FCR0L & 0x0020)) { err = get_flash_error (); if (err) { putchar (0xE1); putword (err); return FALSE; } else return TRUE; } } ... After erase I check IFLASH on a template 0xFF. All passes successfully. Then I start to write down in IFLASH And here I have an error 10ER in to 0x0002 address. The writing code in to IFLASH looks as follows: ... dest = dest | 0x010000; while (size) { FCR0H = 0x0080;//Set the Select Module bit to work on the IFlash FCR0H = FCR0H | 0x2000;//Set the Word Programming Bit FAR = dest;//Load the Address FDR0 = * ((WORD xhuge *) src);//Load the Data FCR0H = FCR0H | 0x8000;//Set the Write Mode Start Bit delay500us (); while (FCR0L & 0x0010); while (FCR0L & 0x0020); err = get_flash_error (); if (err || flash_is_busy ()) { putchar (0xE3); putword ((WORD) src); putword (err); return FALSE; } src + = sizeof (WORD); dest + = sizeof (WORD); size - = sizeof (WORD); } ... Where I can have an error?