如题,项目要用到大容量NAND FLASH,选了,K9F1G08U0C 芯片
IO引脚按如下配置,
void FMC_NAND_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
FMC_NANDInitTypeDef FMC_NANDInitStructure;
FMC_NAND_PCCARDTimingInitTypeDef p;
/* Enable FMC, GPIOD, GPIOE and AFIO clocks */
RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FMC, ENABLE);
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE |
RCC_AHB1Periph_GPIOG , ENABLE);
/*-- GPIO Configuration ------------------------------------------------------*/
/* CLE, ALE, D0->D3, NOE, NWE and NCE2 NAND pin configuration */
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_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_PinAFConfig(GPIOD, GPIO_PinSource0, GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource1, GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource4, GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource5, GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource6, GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource7, GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource11, GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource12, GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource14, GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource15, GPIO_AF_FMC);
GPIO_Init(GPIOD, &GPIO_InitStructure);
/* D4->D7 NAND pin configuration */
GPIO_PinAFConfig(GPIOE, GPIO_PinSource7, GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE, GPIO_PinSource8, GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE, GPIO_PinSource9, GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE, GPIO_PinSource10, GPIO_AF_FMC);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/* NWAIT NAND pin configuration */
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
// GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_PinAFConfig(GPIOG, GPIO_PinSource9, GPIO_AF_FMC);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_Init(GPIOG, &GPIO_InitStructure);
/* INT2 NAND pin configuration */
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
// GPIO_Init(GPIOG, &GPIO_InitStructure);
/*-- FMC Configuration ------------------------------------------------------*/
p.FMC_SetupTime = 0x1;
p.FMC_WaitSetupTime = 0x3;
p.FMC_HoldSetupTime = 0x2;
p.FMC_HiZSetupTime = 0x1;
FMC_NANDInitStructure.FMC_Bank = FMC_Bank2_NAND;
FMC_NANDInitStructure.FMC_Waitfeature = FMC_Waitfeature_Enable;
FMC_NANDInitStructure.FMC_MemoryDataWidth = FMC_NAND_MemoryDataWidth_8b;
FMC_NANDInitStructure.FMC_ECC = FMC_ECC_Enable;
FMC_NANDInitStructure.FMC_ECCPageSize = FMC_ECCPageSize_2048Bytes;
FMC_NANDInitStructure.FMC_TCLRSetupTime = 0x00;
FMC_NANDInitStructure.FMC_TARSetupTime = 0x00;
FMC_NANDInitStructure.FMC_CommonSpaceTimingStruct = &p;
FMC_NANDInitStructure.FMC_AttributeSpaceTimingStruct = &p;
FMC_NANDInit(&FMC_NANDInitStructure);
/* FMC NAND Bank Cmd Test */
FMC_NANDCmd(FMC_Bank2_NAND, ENABLE);
}
运行读ID程序,读出的ID为全为0,,请问是那里出问题了?
void FMC_NAND_ReadID(NAND_IDTypeDef* NAND_ID)
{
uint32_t data = 0;
/* Send Command to the command area */
*(vu8 *)(NAND_FLASH_START_ADDR | CMD_AREA) = 0x90;
*(vu8 *)(NAND_FLASH_START_ADDR | ADDR_AREA) = 0x00;
/* Sequence to read ID from NAND flash */
data = *(vu32 *)(NAND_FLASH_START_ADDR | DATA_AREA);
NAND_ID->Maker_ID = ADDR_1st_CYCLE (data);
NAND_ID->Device_ID = ADDR_2nd_CYCLE (data);
NAND_ID->Third_ID = ADDR_3rd_CYCLE (data);
NAND_ID->Fourth_ID = ADDR_4th_CYCLE (data);
}
一周热门 更多>