我用的是自己照着合纵达的开发板画的板子,硬件连接确定没有问题。
FLASH型号:Am29LV033C
我用一个合纵达提供的flash擦除和烧写的例程的时候,一直会死在擦除和写FLASH的函数的While循环那
以下是擦除函数和写函数,麻烦大家看看,一块讨论讨论,我会关注本帖的,谢谢大家
void SEEDDM642_FLASH_erase(Uint32 start, Uint32 length)
{
Int16 i;
Uint8 *pdata;
Uint32 sector_base, end;
/* Calculate extents of range to erase */
end = start + length – 1;
/* Walk through each sector, erase any sectors within range */
sector_base = SEEDDM642_FLASH_BASE;
for (i = 0; i < SEEDDM642_FLASH_SECTORS; i++)
{
if ((start <= sector_base) && (sector_end[i] <= end))
{
/* Start sector erase sequence */
*((Uint8 *)SEEDDM642_FLASH_BASE) = 0xAA;
// SEEDDM642_wait(1000);
*((Uint8 *)SEEDDM642_FLASH_BASE) = 0x55;
// SEEDDM642_wait(1000);
*((Uint8 *)SEEDDM642_FLASH_BASE) = 0x80;
//SEEDDM642_wait(1000);
*((Uint8 *)SEEDDM642_FLASH_BASE) = 0xAA;
// SEEDDM642_wait(1000);
*((Uint8 *)SEEDDM642_FLASH_BASE) = 0x55;
// SEEDDM642_wait(1000);
// *((Uint8 *)SEEDDM642_FLASH_BASE) = 0x10;
/* Start erase at sector address */
pdata = (Uint8 *)sector_base;
*pdata = 0x30;
SEEDDM642_wait(1000);
/* Wait for erase to complete */
while (1)
{
if (*pdata & 0xff)//程序死在这个while循环中
{
break;
}
}
/* Put back in read mode */
*((Uint8 *)SEEDDM642_FLASH_BASE) = 0xf0;
}
/* Advance to next sector */
sector_base = sector_end[i] + 1;
}
}
烧写函数
void SEEDDM642_FLASH_write(Uint32 src, Uint32 dst, Uint32 length)
{
Uint8 *psrc, *pdst;
Uint32 i;
/* Establish source and destination */
psrc = (Uint8 *)src;
pdst = (Uint8 *)dst;
for (i = 0; i < length; i++)
{
// Program one 8-bit word
*((Uint8 *)SEEDDM642_FLASH_BASE) = 0xaa;
*((Uint8 *)SEEDDM642_FLASH_BASE) = 0x55;
*((Uint8 *)SEEDDM642_FLASH_BASE) = 0xa0;
*pdst = *psrc;
// Wait for operation to complete
while(1)///这个循环也死
{
if (*pdst == *psrc)
{
break;
}
}
// SEEDDM642_waitusec(10000);
pdst++;
psrc++;
}
/* Put back in read mode */
*((Uint16 *)SEEDDM642_FLASH_BASE) = 0xf0;
}
帮我顶下啊,我为这个问题愁一个月了,始终找不到解决办法
Shine:
量一下擦除, 烧写的时序, 看是否和flash数据手册中的一样
KITCHEN:
回复 Shine:
全完一样
Shine:
回复 KITCHEN:
你擦除能成功吗? 量过时序跟flash命令时序要求一样吗?
KITCHEN:
回复 Shine:
没有。我测量过每个时序,是f符合lash的时序要求的,但是结果还是不能擦除。
Eason Wang:
回复 KITCHEN:
请先确定一下WP write protection 管脚电平是否符合要求?如果是错误电平那肯定不行;甚至是中间电平都可能造成误判。