最近在调STM32F4的FMC有个奇怪的现象,NOE管脚一致是低电平,好奇怪,是不是我FMC配置有误,大家帮忙看看:
void FMC_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOF|RCC_AHB1Periph_GPIOG, ENABLE);//????PD,PE,PF,PG?±??
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15;//PB15 ???ì????,????±???
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;//???¨????????
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//???ì????
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;//????
GPIO_Init(GPIOB, &GPIO_InitStructure);//?????? //PB15 ???ì????,????±???
GPIO_InitStructure.GPIO_Pin = (3<<0)|(3<<4)|(7<<8)|(3<<14);//PD0,1,4,5,8,9,10,14,15 AF OUT
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//????????
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//???ì????
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//????
GPIO_Init(GPIOD, &GPIO_InitStructure);//??????
GPIO_InitStructure.GPIO_Pin = (0X1FF<<7);//PE7~15,AF OUT
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//????????
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//???ì????
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//????
GPIO_Init(GPIOE, &GPIO_InitStructure);//??????
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;//PF12,FSMC_A6
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//????????
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//???ì????
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//????
GPIO_Init(GPIOG, &GPIO_InitStructure);//??????
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;//PG12,FSMC_NE4
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;//????????
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;//???ì????
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;//100MHz
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;//????
GPIO_Init(GPIOG, &GPIO_InitStructure);//??????
GPIO_PinAFConfig(GPIOD,GPIO_PinSource0,GPIO_AF_FMC);//PD0,AF12
GPIO_PinAFConfig(GPIOD,GPIO_PinSource1,GPIO_AF_FMC);//PD1,AF12
GPIO_PinAFConfig(GPIOD,GPIO_PinSource4,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource5,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource8,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource9,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource10,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource14,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOD,GPIO_PinSource15,GPIO_AF_FMC);//PD15,AF12
GPIO_PinAFConfig(GPIOE,GPIO_PinSource7,GPIO_AF_FMC);//PE7,AF12
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_PinAFConfig(GPIOE,GPIO_PinSource11,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource12,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource13,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource14,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOE,GPIO_PinSource15,GPIO_AF_FMC);
GPIO_PinAFConfig(GPIOG,GPIO_PinSource0,GPIO_AF_FMC);//PF12,AG6
GPIO_PinAFConfig(GPIOG,GPIO_PinSource12,GPIO_AF_FMC);
}
void FMC_Init(void)
{
FMC_NORSRAMInitTypeDef FMC_NORSRAMInitStructure;
FMC_NORSRAMTimingInitTypeDef readWriteTiming;
FMC_NORSRAMTimingInitTypeDef writeTiming;
RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FMC,ENABLE);//????FSMC?±??
writeTiming.FMC_AddressSetupTime =9; //???·?¨???±???¨ADDSET?©??9??HCLK =54ns
writeTiming.FMC_AddressHoldTime = 0x00; //???·±????±???¨A
writeTiming.FMC_DataSetupTime = 8; //????±????±????6ns*9??HCLK=54ns
writeTiming.FMC_BusTurnAroundDuration = 0x00;
writeTiming.FMC_CLKDivision = 0x00;
writeTiming.FMC_DataLatency = 0x00;
writeTiming.FMC_AccessMode = FMC_AccessMode_A; //????A
FMC_NORSRAMInitStructure.FMC_Bank = FMC_Bank1_NORSRAM4;// ????????????NE4 ??????????BTCR[6],[7]??
FMC_NORSRAMInitStructure.FMC_DataAddressMux = FMC_DataAddressMux_Disable; // ?????????????·
FMC_NORSRAMInitStructure.FMC_MemoryType =FMC_MemoryType_NOR;// FSMCEnable_MemoryType_SRAM; //SRAM
FMC_NORSRAMInitStructure.FMC_MemoryDataWidth = FMC_NORSRAM_MemoryDataWidth_16b;//?????÷?????í????16bit
FMC_NORSRAMInitStructure.FMC_BurstAccessMode =FMC_BurstAccessMode_Disable;// FSMC_BurstAccessMode_Disable;
FMC_NORSRAMInitStructure.FMC_WaitSignalPolarity = FMC_WaitSignalPolarity_Low;
FMC_NORSRAMInitStructure.FMC_AsynchronousWait=FMC_AsynchronousWait_Disable;
FMC_NORSRAMInitStructure.FMC_WrapMode = FMC_WrapMode_Disable;
FMC_NORSRAMInitStructure.FMC_WaitSignalActive = FMC_WaitSignalActive_BeforeWaitState;
FMC_NORSRAMInitStructure.FMC_WriteOperation = FMC_WriteOperation_Enable; // ?????÷??????
FMC_NORSRAMInitStructure.FMC_WaitSignal = FMC_WaitSignal_Disable;
FMC_NORSRAMInitStructure.FMC_ExtendedMode = FMC_ExtendedMode_Enable; // ???????????????±?ò
FMC_NORSRAMInitStructure.FMC_AsynchronousWait = FMC_AsynchronousWait_Disable;
FMC_NORSRAMInitStructure.FMC_WriteBurst = FMC_WriteBurst_Disable;
FMC_NORSRAMInitStructure.FMC_ContinousClock = FMC_CClock_SyncOnly;
FMC_NORSRAMInitStructure.FMC_ReadWriteTimingStruct = &readWriteTiming; //?????±?ò
FMC_NORSRAMInitStructure.FMC_WriteTimingStruct = &writeTiming; //???±?ò
FMC_NORSRAMInit(&FMC_NORSRAMInitStructure); //??????FSMC????
FMC_NORSRAMCmd(FMC_Bank1_NORSRAM4, ENABLE); // ????BANK1
}
这个是读操作:
第一个是写寄存器地址,第二个是读操作,但是整个过程NOE都是低电平!好不理解啊!
一周热门 更多>