初级会员

- 积分
- 65
- 金钱
- 65
- 注册时间
- 2013-8-19
- 在线时间
- 22 小时
|
1金钱
如果NAND FLASH 读取不到ID的话 硬件上应该怎么检测?初始化代码如下
static void nandFlash_IOInit()
{
GPIO_InitTypeDef GPIO_InitStructure;
FSMC_NANDInitTypeDef FSMC_NANDInitStructure;
FSMC_NAND_PCCARDTimingInitTypeDef p;
/* ê1Äü FSMC ê±Öó */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
/* ê1ÄüGPIOD¡¢GPIOE¡¢GPIOF¡¢GPIOG ê±Öó */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE |
RCC_APB2Periph_GPIOF | RCC_APB2Periph_GPIOG, ENABLE);
/* GPIO ÅäÖÃ */
/* ¿ØÖÆÏßCLE, ALE, D0-D3, NOE, NWE oí NCE2 NAND òy½ÅÅäÖÃÎa¸′óÃ1|Äü£¨¼′óÃóúFSMC) */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_14 | GPIO_Pin_15 |
GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 |
GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* êy¾YÏß D4-D7 òy½ÅÅäÖÃÎa¸′óÃ1|Äü */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10;
GPIO_Init(GPIOE, &GPIO_InitStructure);
//NEC3
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 ;
GPIO_Init(GPIOG, &GPIO_InitStructure);
/* INT2 òy½ÅÅäÖÃÎaÄú2¿éÏà′êäè룬óÃóúÃ|DÅoÅ */
//PG6-INT2 PG7-INT3
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOG, &GPIO_InitStructure);
}
static void nandFlash_FSMCInit(uint32_t fsmcbankNum)
{
FSMC_NANDInitTypeDef FSMC_NANDInitStructure;
FSMC_NAND_PCCARDTimingInitTypeDef p;
/* FSMC ÅäÖÃ */
p.FSMC_SetupTime = 0x1;
p.FSMC_WaitSetupTime = 0x3;
p.FSMC_HoldSetupTime = 0x2;
p.FSMC_HiZSetupTime = 0x1;
FSMC_NANDInitStructure.FSMC_Bank = fsmcbankNum; /* ¶¨òåFSMC BANK oÅ */
FSMC_NANDInitStructure.FSMC_Waitfeature = FSMC_Waitfeature_Enable; /* 2åèëμè′yê±Dòê1Äü */
FSMC_NANDInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; /* êy¾Y¿í¶è 8bit */
FSMC_NANDInitStructure.FSMC_ECC = FSMC_ECC_Enable; /* ECC′íÎó¼ì2éoí¾àÕy1|Äüê1Äü */
FSMC_NANDInitStructure.FSMC_ECCPageSize = FSMC_ECCPageSize_2048Bytes; /* ECC ò3Ãæ′óD¡ */
FSMC_NANDInitStructure.FSMC_TCLRSetupTime = 0x00;
FSMC_NANDInitStructure.FSMC_TARSetupTime = 0x00;
FSMC_NANDInitStructure.FSMC_CommonSpaceTimingStruct = &p;
FSMC_NANDInitStructure.FSMC_AttributeSpaceTimingStruct = &p;
FSMC_NANDInit(&FSMC_NANDInitStructure);
/* FSMC NAND Bank ê1Äü */
FSMC_NANDCmd(fsmcbankNum, ENABLE);
}
void nandFlash_Init()
{
uint32_t picFlashID=0;
uint32_t fontFlashID=0;
u8 testflashRes=0;
nandFlash_IOInit();
nandFlash_FSMCInit(FSMC_Bank2_NAND);
FSMC_NAND_Reset(NAND_PicLib); /* í¨1y¸′λÃüáî¸′λNAND Flashμ½¶á×′ì¬ */
picFlashID=NAND_ReadID(NAND_PicLib);
printf("U2 picFlashID=%x\r\n",picFlashID);
NAND_ScanBlock(NAND_PicLib,2);
}
|
|