最近在调
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_NORSRAM
timingInitTypeDef 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都是低电平!好不理解啊!
哦哦,三克油。
一周热门 更多>