1、
STM32F103ZET6上配置的FSMC模拟8080用于刷新OLED(256*64),使用正常;2、移植至STM32F412RET6后无法使用,时钟、复用、FSMC均已配置,使用NE4、A0,配置写入命令地址为0x6C00000,写入数据地址为0x6C000001;错误现象为:①屏幕显示现象为雪花屏②用逻辑分析仪测得D0-D3数据线无信号输出,仅有高电平。配置已检查过多遍,麻烦各位给一些思路解决一下这个问题,感谢!
代码如下:
/** RS(DC)——A0——PC3 RD——FSMC_NOE——PC5* WR——FSMC_NWE——PC2 D0——FSMC_D0——PB14* D1——FSMC_D1——PC6 D2——FSMC_D2——PC11* D3——FSMC_D3——PC12 D4——FSMC_D4——PA2* D5——FSMC_D5——PA3 D6——FSMC_D6——PA4* D7——FSMC_D7——PA5 CS——FSMC_NE4——PC4* RESET——PB13*//*******************************************************************************@name :InitOLED@brief :按键初始化@param :None@return :None*******************************************************************************/void InitOLED (void){ GPIO_InitTypeDef GPIO_InitStructure; /*GPIOA、B、C时钟使能*/ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA|RCC_AHB1Periph_GPIOB|RCC_AHB1Periph_GPIOC, ENABLE); /*WR、RS、CS、RD、D1、D2、D3推挽复用输出*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_11|GPIO_Pin_12; 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_UP; GPIO_Init(GPIOC, GPIO_InitStructure); /*D0推挽复用输出*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14; GPIO_Init(GPIOB, GPIO_InitStructure); /*D4、D5、D6、D7推挽复用输出*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5; GPIO_Init(GPIOA, GPIO_InitStructure); GPIO_PinAFConfig(GPIOC, GPIO_PinSource2, GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOC, GPIO_PinSource3, GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOC, GPIO_PinSource4, GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOC, GPIO_PinSource5, GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOC, GPIO_PinSource11, GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOC, GPIO_PinSource12, GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOB, GPIO_PinSource14, GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_FSMC); /*RESET推挽输出*/ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOB, GPIO_InitStructure); InitFSMC();}void InitFSMC(void){ FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; FSMC_NORSRAM
timingInitTypeDef readWriteTiming; FSMC_NORSRAMTimingInitTypeDef writeTiming; /*FSMC时钟使能*/ RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC,ENABLE); /*读时序设置*/ readWriteTiming.FSMC_AddressSetupTime = 0x01; readWriteTiming.FSMC_AddressHoldTime = 0x00; readWriteTiming.FSMC_DataSetupTime = 0x02; readWriteTiming.FSMC_BusTurnAroundDuration = 0x00; readWriteTiming.FSMC_CLKDivision = 0x00; readWriteTiming.FSMC_DataLatency = 0x00; readWriteTiming.FSMC_AccessMode = FSMC_AccessMode_A; /*写时序设置*/ writeTiming.FSMC_AddressSetupTime = 0x01; writeTiming.FSMC_AddressHoldTime = 0x00; writeTiming.FSMC_DataSetupTime = 0x02; writeTiming.FSMC_BusTurnAroundDuration = 0x00; writeTiming.FSMC_CLKDivision = 0x00; writeTiming.FSMC_DataLatency = 0x00; writeTiming.FSMC_AccessMode = FSMC_AccessMode_A; FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM4; //使用NE4 FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable; //不复用数据地址 FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM; // FSMC_MemoryType_SRAM; FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b; //存储器数据宽度为8bit FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; // FSMC_BurstAccessMode_Disable; FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable; FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; //存储器写使能 FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable; //读写使用不同的时序 FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable; FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = readWriteTiming; //读写时序 FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = writeTiming; //写时序 FSMC_NORSRAMInit( FSMC_NORSRAMInitStructure); //初始化FSMC配置 FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4, ENABLE); //使能BANK1}/*******************************************************************************@name :Write_cmd@brief :SPI写入命令函数@param :None@return :None*******************************************************************************/void Write_cmd(u8 data){ data=data; * (__IO u8 *)(FSMC_ADDR_CMD) = data;}/*******************************************************************************@name :Write_Data@brief :SPI写入数据函数@param :None@return :None*******************************************************************************/void Write_Data(u8 data){ data=data; * (__IO u8 *)(FSMC_ADDR_DATA) = data;}#define FSMC_ADDR_DATA ((u32) 0x6C000000 | (1<<0))#define FSMC_ADDR_CMD ((u32) 0x6C000000)