系统结构与功能:
lpc3131外接8k*8双口ram与8G Flash,从双口ram读取数据(来自FPGA),并存至Flash中。
问题:
丢数据,系统速度远低于ram的读速与Flash的写速度。
双口ram读数据直接采用指针,如下:
for(i=0;i<tmp;i++)
{
nandflash.databuf[nandflash.ptr_buf] = *(volatile UNS_8 *)(EXT_SRAM0_0_BASE + ram.ptr);
nandflash.ptr_buf++;
ram.ptr++;
}
Flash按页写的程序如下:
INT_32 nand_page_write(INT_32 devid,
void * buffer,
INT_32 bank_num,
INT_32 block_num,
INT_32 page_num)
NAND_DRV_T *nanddrv = (NAND_DRV_T *) devid;
NAND_FLASH_CTRL_REGS_T *nandreg = nanddrv->regptr;
UNS_32 * pData;
UNS_32 * pnfbuf[2];
UNS_32 i,j,tmp;
UNS_8 addr1 = 0;
UNS_8 addr2 = 0;
UNS_8 addr3 = (UNS_8)(((block_num<<6)&0x0C0)+(page_num&0x03F));
UNS_8 addr4 = (UNS_8)((block_num>>2)&0x0FF);
UNS_8 addr5 = (UNS_8)((block_num>>10)&0x07);
pnfbuf[0] = (UNS_32 *) NANDFLASH_CTRL_S0_BASE;
pnfbuf[1] = (UNS_32 *) (NANDFLASH_CTRL_S0_BASE + 0x400);
nandreg->set_ce = NAND_SETCE_WP | NAND_SETCE_CV(bank_num);
nandreg->set_cmd = NAND_CMD_SDIN;
nandreg->set_addr = addr1;
nandreg->set_addr = addr2;
nandreg->set_addr = addr3;
nandreg->set_addr = addr4;
nandreg->set_addr = addr5;
for(j=0;j<8;j++)
pData = (UNS_32 *)((UNS_8 *)buffer + j*512);
tmp = j&0x01;
for(i=0;i<128;i++)
*(pnfbuf[tmp]+i) = *(pData + i);
if(j>0)
while(!(nand_ioctl(devid, NAND_IRQ_STATUS, 3-tmp)));
while((nand_ioctl(devid, NAND_IRQ_STATUS, 3-tmp)))nandreg->irq_status_raw = 0xFFFFFFFF;
nandreg->control_flow = NAND_CTRL_RD_RAM(4+tmp);
while(!(nand_ioctl(devid, NAND_IRQ_STATUS, 3)));
while((nand_ioctl(devid, NAND_IRQ_STATUS, 3)))nandreg->irq_status_raw = 0xFFFFFFFF;
nandreg->set_cmd = NAND_CMD_PAGEPROG;
while((nand_ioctl(devid, NAND_RB_STATUS, bank_num)));
while(!(nand_ioctl(devid, NAND_RB_STATUS, bank_num)));
return 0;
为什么速度远低于芯片说明文档中的读写速度???
求指点,非常感谢!
Hello Superccc,
你好,长假期间,回复可能有点慢,等上班后会尽快安排回复。
不好意思
谢谢