И если да, то где я ошибся (функция очистки сектора):
Код
#define SEQ_ADR_1 ((__far volatile unsigned int*)0xFFAAAA)
#define SEQ_ADR_2 ((__far volatile unsigned int*)0xFF5554)
#define DQ7 0x0080
#define DQ5 0x0020
int fm_sectorErase(__far unsigned int *sector_adr)
{
int flag = 0;
// start with chip erase sequence
FMCS_WE = 1; // set write enable flag
*SEQ_ADR_1 = 0x00AA; // sends the command to the pointed address
*SEQ_ADR_2 = 0x0055;
*SEQ_ADR_1 = 0x0080;
*SEQ_ADR_1 = 0x00AA;
*SEQ_ADR_2 = 0x0055;
*sector_adr = 0x0030; // erase sector at the pointed address
while(flag == 0)
{
if((*sector_adr & DQ7) == DQ7) // Toggle bit
{
flag = 1; // successful erased
}
if((*sector_adr & DQ5) == DQ5) // time out
{
if((*sector_adr & DQ7) == DQ7)
{
flag = 1; // successful erased
}
else
{
flag = 2; // timeout error
}
}
}
FMCS_WE = 0; // reset write enable flag
return(flag);
}
#define SEQ_ADR_2 ((__far volatile unsigned int*)0xFF5554)
#define DQ7 0x0080
#define DQ5 0x0020
int fm_sectorErase(__far unsigned int *sector_adr)
{
int flag = 0;
// start with chip erase sequence
FMCS_WE = 1; // set write enable flag
*SEQ_ADR_1 = 0x00AA; // sends the command to the pointed address
*SEQ_ADR_2 = 0x0055;
*SEQ_ADR_1 = 0x0080;
*SEQ_ADR_1 = 0x00AA;
*SEQ_ADR_2 = 0x0055;
*sector_adr = 0x0030; // erase sector at the pointed address
while(flag == 0)
{
if((*sector_adr & DQ7) == DQ7) // Toggle bit
{
flag = 1; // successful erased
}
if((*sector_adr & DQ5) == DQ5) // time out
{
if((*sector_adr & DQ7) == DQ7)
{
flag = 1; // successful erased
}
else
{
flag = 2; // timeout error
}
}
}
FMCS_WE = 0; // reset write enable flag
return(flag);
}
На реальном девайсе проверить пока нет возможности (собирают еще).