- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear sir
I use IC MB95F698K in codding. while i was erasing sector 3 , I found my code was stopped after erased sector address. below my code.
#define SA3 ((unsigned char *) 0x8000)
#define seq_8AAA ((volatile unsigned char *)0x8AAA)
#define seq_8554 ((volatile unsigned char *)0x8554)
void main(void){
LVDPW = 0xC8;
LVDCC_LVDEON = 0;
SYSC_RSTOE = 0;
SYSC_RSTEN = 0;
SYCC = 0xD8; // 4MHz
FSR_SSEN=1; //Swap SA3 2Kbytes top to SA1
erase_sector3(SA3);
/*................ task...........................*/
..........
.....
.....
....
}
int erase_sector3(unsigned char *adr ){
unsigned int flag;
unsigned char data_ee_timeout;
flag=0;
data_ee_timeout = 20;
FSR_WRE = 1; // programming enable
SWRE0 = 0x0F;
*seq_8AAA = 0xAA; // Send erase commands to SA3
*seq_8554 = 0x55;
*seq_8AAA = 0x80;
*seq_8AAA = 0xAA;
*seq_8554 = 0x55;
*adr= 0x30; // Erase !!!
while((flag==0)&&(data_ee_timeout)) // <<<<< Stop this point.
{
WDTC=0x35; //Clear watch dog timer
data_ee_timeout--;
if((*adr & DQ7) == DQ7) // Check Data polling bit
{
flag = 1; // Successfull Erase
}
if((*adr & DQ5) == DQ5) // Check Timeout bit
{
if((*adr & DQ7) == DQ7)
{
flag = 1; // Successfull Erase
}
else flag = 2; // Timeout error during erase
}
}
FSR_WRE = 0;
return(flag)
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are the code you posted is runing on another controller? which is to erase flash content of MB95F698K ?
I didnot figure out how the (flag==0)&&(data_ee_timeout) can =1 when it is reached the first time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your comment.
1.Are the code you posted is runing on another controller?
Ans >> I run on MB95F698K by debug of softune workbench.
2.which is to erase flash content of MB95F698K ?
Ans>> In loop main i call function erase_sector3(SA3) and i sent first address of sector 3 is 0x8000. I did it following flash memory command sequence table.
int erase_sector3(unsigned char *adr ){
unsigned int flag;
unsigned char data_ee_timeout;
flag=0;
data_ee_timeout = 20;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////// This code erase sector 3 in flash memory of MB95F698K.////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
FSR_WRE = 1; // programming enable
SWRE0 = 0x0F; // enable sector 0,1,2,3
*seq_8AAA = 0xAA; //
*seq_8554 = 0x55;
*seq_8AAA = 0x80;
*seq_8AAA = 0xAA;
*seq_8554 = 0x55;
*adr= 0x30; // Erase !!!
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// To check erase completed and time out.
while((flag==0)&&(data_ee_timeout))
3.I didnot figure out how the (flag==0)&&(data_ee_timeout) can =1 when it is reached the first time.
Ans >> (flag==0)&&(data_ee_timeout) // I define flag=0 and data_ee_timeout =20 at first time. if this line flag==0 mean true and data_ee_timeout != 0 mean true. when it is reached at that line, it was stopped this line. Actually ,it should run continue.
Note. when i erased sector 0,1,2 . It wasn't stopped at that line. just sector 3 only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The flash size of MB95F698 is 60K which includes two bank:
upper bank: 32 Kbyte × 1 + 24 Kbyte × 1;
lower bank: 2 Kbyte × 2
Attention please:
From the user manual "Data can be updated by executing a program in RAM or by executing a program in the Flash
memory in dual operation. The erase/program operation and the read operation can be executed
in different banks (upper bank/lower bank) simultaneously".
The code of flash operation, you can also refer to the URL: MB95F718m
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank for your suggestion
I did following for your suggestion but it still was stopped at the same point.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry for late reply.
I'd like to confirm how could recognize the code stops at that line, code just gets stuck?
What are the values of flag and data_ee_timeout at the time code stops?