初中生
最后登录 1970-1-1
在线时间 小时
注册时间 2015-5-25
100 火花
FlexSPI挂载了两片FLASH,kFLEXSPI_PortA1端口挂载了nor flash,kFLEXSPI_PortB1端口挂载了nand flash,参考了FLEXSPI读写W25Q256的例程代码来读取kFLEXSPI_PortB1的NAND FLASH设备ID,结果返回的是的是W24Q256的设备ID,用示波器测试发现访问kFLEXSPI_PortB1的时候片选信号没有任何电平变化(片选信号不生效,片选信号不生效,片选信号不生效),反而是kFLEXSPI_PortA1的片选有变化,简言而知,我要读取NAND FLASH的设备ID,结果却返回的是NOR FLASH的社设备ID,关于FlexSPI B1端口使用的灵异事件已经塞车了好几天,劳烦各位大神一起探讨一下,留下宝贵建议
uint32_t WB_NAND_Read_JEDEC_ID(void)
{
uint32_t temp,vendorID;
flexspi_transfer_t FlashTransfer;
FlashTransfer.deviceAddress=0; //地址
FlashTransfer.port=kFLEXSPI_PortB1; //端口
FlashTransfer.cmdType=kFLEXSPI_Read; //操作类型:读数据
FlashTransfer.SeqNumber=1; //序号
FlashTransfer.seqIndex=NOR_CMD_LUT_SEQ_IDX_READ_JEDEC_ID; //LUT表中命令索引
FlashTransfer.data=&temp; //读到的数据
FlashTransfer.dataSize=3; //读的数据长度
/* 开始阻塞传输 */
status_t status = FLEXSPI_TransferBlocking(FLEXSPI,&FlashTransfer);
/* 调整高低字节,结果赋值到 vendorId */
vendorID = ((temp&0xFF)<<16) | (temp&0xFF00) | ((temp&0xFF0000)>>16);
PRINTF("status:%d temp=0x%x vendorID=0x%x\r\n",status,temp,vendorID);
return vendorID;
}
//初始化FlexSPI Nand Flash
void FlexSPI_FlashInit(void)
{
//W25N01GVZEIG最高104MHz
//初始化FlexSPI时钟,W25Q128JV最高可以到133MHz
CLOCK_InitUsb1Pfd(kCLOCK_Pfd0,24); //设置PLL3的PFD0为480Mhz*18/24=360MHz
CLOCK_SetMux(kCLOCK_FlexspiMux,0x3); //FlexSPI时钟源选择PLL3 PFD0
CLOCK_SetDiv(kCLOCK_FlexspiDiv,3); //FlexSPI时钟设置为360/(3+1)=90Mhz
//配置FlexSPI所使用的IO的复用功能
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_00_FLEXSPIB_DATA03,0);
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_01_FLEXSPIB_DATA02,0);
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_02_FLEXSPIB_DATA01,0);
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_03_FLEXSPIB_DATA00,0);
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_04_FLEXSPIB_SCLK,0);
IOMUXC_SetPinMux(IOMUXC_GPIO_SD_B1_05_FLEXSPIB_SS0_B,0);
//高转换速度,驱动能力为R0/6,速度为200Mhz,关闭开路功能,使能pull/keepr
//选择keeper功能,下拉100K Ohm,关闭Hyst
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_00_FLEXSPIB_DATA03,0x10F1);
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_01_FLEXSPIB_DATA02,0x10F1);
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_02_FLEXSPIB_DATA01,0x10F1);
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_03_FLEXSPIB_DATA00,0x10F1);
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_04_FLEXSPIB_SCLK,0x10F1);
IOMUXC_SetPinConfig(IOMUXC_GPIO_SD_B1_05_FLEXSPIB_SS0_B,0x10F1);
SCB_DisableDCache();
/*Get FLEXSPI default settings and configure the flexspi. */
FLEXSPI_GetDefaultConfig(&flexspi_norflash_config);
/*Set AHB buffer size for reading data through AHB bus. */
flexspi_norflash_config.ahbConfig.enableAHBPrefetch=true;
FLEXSPI_Init(FLEXSPI,&flexspi_norflash_config);
/* Configure flash settings according to serial flash feature. */
FLEXSPI_SetFlashConfig(FLEXSPI,&NandFlash_config,kFLEXSPI_PortB1);
/* Update LUT table. */
FLEXSPI_UpdateLUT(FLEXSPI, 0, FlexSPI_LUT, CUSTOM_LUT_LENGTH);
WB_NAND_Read_JEDEC_ID();
}
我来回答