|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
通过在xilinx EDk上编写flash的代码程序实现:(我的板子是spartan-3 2000,flash是intel 的J3)。
问题是这样的:
按照下面的代码在xilinx EDK上能够的实现flash擦除、读写操作,并且通过超级终端进行验证,显示擦读写操作正确。
那么按照这个程序应该实现了对开发板上flash的擦读写操作,开发板上的flash数据应该进行了更新。
可是通过xilinx ISE编写.v文件去读取开发板上的flash,发现读取到的flash内容没有改变,和之前没有对flash进行更新之前的数据一样。
请教大家这是什么问题?非常谢谢!
代码如下:
/ Perform a Chip Erase, one block at a time
xil_printf("Erasing %d blocks, starting...\n\r", BLOCKS_TO_ERASE);
// Perform a Chip Erase
for(i = 0; i < BLOCKS_TO_ERASE; i ++)
//for(i = 0; i < 2; i ++)
{
// Erase Sector command
XIo_Out32(FLASHBASEADDR+(i*0x8000 << 2),0x00200020);
XIo_Out32(FLASHBASEADDR+(i*0x8000 << 2),0x00D000D0);
xil_printf("Erase block %d\r\n",i);
XIo_Out32(FLASHBASEADDR + (i*0x8000 << 2),0x00700070);
do
{
// Read status register
TempWord32 = XIo_In32(FLASHBASEADDR + (i*0x8000 << 2));
//xil_printf("Read status register %d : %x\n\r ", i, TempWord32);
}
while( (TempWord32 & 0x00800080) != 0x00800080 );
}
xil_printf("\n\rSectors 0-%d erased\n\r", BLOCKS_TO_ERASE-1);
xil_printf("\n\rChip Erase complete - verifying\n\r");
XIo_Out32(FLASHBASEADDR + (i*0x1000 << 1),0x00FF00FF);
// Verify Chip Erase
// Readback entire chip, comparing to 0xFFFFFFFF
for (i = 0; i < FLASHWORDS; i++)
//for (i = 0; i < 1000; i++)
{
DataWord32 = XIo_In32(FLASHBASEADDR + (i<<2) );//why i<<2 ?
// xil_printf("N0: %d Data read was %x\n\r",i,DataWord32);
if (DataWord32 != 0xFFFFFFFF)
{
xil_printf("Chip Erase Failed at %x\n\r", i);
xil_printf("Data read was %x\n\r",DataWord32);
error = 1;
//i = TEST_WORDS;
}
}
if(!error)
xil_printf("Chip Erased successfully\n\n\r");
// Write Test using Word Program mode
xil_printf("Data being written\n\r");
for (i = 0; i < FLASHWORDS; i++)
//for (i = 0; i < 20; i++)
{
XIo_Out32(FLASHBASEADDR + (i<<2) ,0x00400040);
XIo_Out32(FLASHBASEADDR + (i<<2) ,i*19);
XIo_Out32(FLASHBASEADDR + i,0x00700070);
do
{
// Read status register command
TempWord32 = XIo_In32(FLASHBASEADDR + i);
//xil_printf("%d ----%x \n\r ", i,TempWord32);
}
while( (TempWord32 & 0x00800080) != 0x00800080 );
}
xil_printf("Test Data Written; reading back\n\r", i);
XIo_Out32(FLASHBASEADDR +100,0x00FF00FF);
// Readback
error = 0;
for (i = 0; i < FLASHWORDS;i++ )
//for (i = 0; i <20;i++)
{
DataWord32 = XIo_In32(FLASHBASEADDR + (i<<2));// read mode?
//xil_printf("%d Data read was %x\n\r",i,DataWord32);
TestWord32 =i*19;
if (DataWord32 != TestWord32)
{
xil_printf("Flash Test FAILED at 0x%x\n\r", i);
xil_printf("Data read was 0x%x\n\r",DataWord32);
xil_printf("Exp. Data was 0x%x\n\r",TestWord32);
error = 1;
i = FLASHWORDS;
}
}
if(!error)
{
xil_printf("Flash Test PASSED!\n\r");
xil_printf("Ending Address Read was 0x%x\n\r", i);
xil_printf("Last Data Read was %x\n\r", DataWord32);
} |
|