完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
代码清单(一):主要是配置相关应用接口和GPIO复用引脚: //以下主要是配置LCD的相应管脚,可以根据上面的PCB信息得到连接的引脚: void LCD_GPIO_Config(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD|RCC_AHB1Periph_GPIOE|RCC_AHB1Periph_GPIOF |RCC_AHB1Periph_GPIOG,ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //配置引脚PF10 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOF,&GPIO_InitStructure); //配置引脚PD0/PD1/PD4/PD5/PD8/PD9/PD10/PD14/PD15 GPIO_InitStructure.GPIO_Pin = (3<<0)|(3<<4)|(7<<8)|(3<<14); 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(GPIOD,&GPIO_InitStructure); //配置引脚PE7-PE15; GPIO_InitStructure.GPIO_Pin = (0x1FF<<7); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOE,&GPIO_InitStructure); //配置引脚PG2和PG12 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_12; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOG,&GPIO_InitStructure); //配置引脚PD0/PD1/PD4/PD5/PD8/PD9/PD10/PD14/PD15 GPIO_PinAFConfig(GPIOD,GPIO_PinSource0,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD,GPIO_PinSource1,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD,GPIO_PinSource4,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD,GPIO_PinSource5,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD,GPIO_PinSource8,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD,GPIO_PinSource9,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD,GPIO_PinSource10,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD,GPIO_PinSource14,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOD,GPIO_PinSource15,GPIO_AF_FSMC); //配置引脚PE7-PE15 GPIO_PinAFConfig(GPIOE,GPIO_PinSource7,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE,GPIO_PinSource8,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE,GPIO_PinSource9,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE,GPIO_PinSource10,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE,GPIO_PinSource11,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE,GPIO_PinSource12,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE,GPIO_PinSource13,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE,GPIO_PinSource14,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOE,GPIO_PinSource15,GPIO_AF_FSMC); //配置复用引脚PG2和PG12; GPIO_PinAFConfig(GPIOG,GPIO_PinSource2,GPIO_AF_FSMC); GPIO_PinAFConfig(GPIOG,GPIO_PinSource12,GPIO_AF_FSMC); } 代码清单(二):主要是配置STM32单片机内部的FSMC: void LCD_Config(void) { FSMC_NORSRAMInitTypeDef FSMC_InitStructure; FSMC_NORSRAMTimingInitTypeDef readTiming; FSMC_NORSRAMTimingInitTypeDef writeTiming; RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC,ENABLE); //配置时序:readTiming结构体 readTiming.FSMC_AddressSetupTime = 0xF;//地址建立时间 readTiming.FSMC_AddressHoldTime = 0x01;//地址保持时间 readTiming.FSMC_DataSetupTime = 0x3C; //数据建立时间 readTiming.FSMC_BusTurnAroundDuration = 0x01;//总线转换时间 readTiming.FSMC_CLKDivision = 0x00; //时钟分频因子 readTiming.FSMC_DataLatency = 0x00;//数据延迟时间 readTiming.FSMC_AccessMode = FSMC_AccessMode_A;//设置存储器访问模式 //配置写时序结构体:writeTiming结构体 writeTiming.FSMC_AddressSetupTime = 0x08; writeTiming.FSMC_AddressHoldTime = 0x01; writeTiming.FSMC_DataSetupTime = 0x07; writeTiming.FSMC_BusTurnAroundDuration = 0x00; writeTiming.FSMC_CLKDivision = 0x00; writeTiming.FSMC_DataLatency = 0x00; writeTiming.FSMC_AccessMode = FSMC_AccessMode_A; //配置FSMC初始化结构体 FSMC_InitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;//用于选择FSMC映射的存储区域 FSMC_InitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;//设置地址总线与 //数据总线是否复 //用; FSMC_InitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;//用于设置需要控制的存储器类 //型 FSMC_InitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;//设置数据宽度 FSMC_InitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;//设置是否使用 //突发模式 FSMC_InitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;//设置是否使 //能数据同步传输时使用使能信号 FSMC_InitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;//设置等待信 //号的有效极性 FSMC_InitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;//设置是否支持把非对称AHB突发 //操作分割成两次线性操作 FSMC_InitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;// FSMC_InitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;// FSMC_InitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable; // FSMC_InitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable;// FSMC_InitStructure.FSMC_ReadWriteTimingStruct = &readTiming; FSMC_InitStructure.FSMC_WriteTimingStruct = &writeTiming; FSMC_NORSRAMInit(&FSMC_InitStructure); FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM4,ENABLE);//ʹÄÜBank1£» delay_ms(50); } |
|
|
|
只有小组成员才能发言,加入小组>>
3294 浏览 9 评论
2970 浏览 16 评论
3473 浏览 1 评论
9023 浏览 16 评论
4061 浏览 18 评论
1140浏览 3评论
589浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
579浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2313浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1876浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-4 02:07 , Processed in 1.246147 second(s), Total 79, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号