找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3103|回复: 1
打印 上一主题 下一主题
收起左侧

STM32+LCD彩色液晶屏显示汉字、英文、数字的程序

[复制链接]
跳转到指定楼层
楼主
ID:415366 发表于 2020-6-1 15:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
共享一份资料,LCD彩色液晶屏显示汉字、英文、数字的程序,适合初学者,单片机用STM32

单片机源程序如下:
  1. #include "pbdata.h"

  2. void RCC_Configuration(void);
  3. void GPIO_Configuration(void);
  4. void NVIC_Configuration(void);
  5. void USART_Configuration(void);

  6. int fputc(int ch,FILE *f)
  7. {
  8.         USART_SendData(USART1,(u8)ch);
  9.         while(USART_GetFlagStatus(USART1,USART_FLAG_TXE)==RESET);
  10.         return ch;
  11. }

  12. int main(void)
  13. {
  14.    u8 i=0;
  15.    RCC_Configuration();        //系统时钟初始化
  16.    GPIO_Configuration();//端口初始化
  17.    USART_Configuration();
  18.    NVIC_Configuration();
  19.    FSMC_Configuration();

  20.    SSD1963_Init();
  21.    delay_ms(1000);
  22.    SSD1963_CLEAR(WHITE);

  23.    for(i=0;i<4;i++)
  24.         {
  25.                 Show_Font(30+i*50,50,i,RED,WHITE);
  26.         }
  27.         
  28.         for(i=0;i<15;i++)
  29.         {
  30.            Show_Str(10+i*15,100,i,RED,WHITE);
  31.         }

  32.     while(1)
  33.         {
  34.                 TFT_Draw_Rectangle(10,150,230,160,RED);
  35.                 delay_ms(200);
  36.                 TFT_Draw_Rectangle(10,150,230,160,BLUE);
  37.                 delay_ms(200);
  38.                 TFT_Draw_Rectangle(10,150,230,160,GREEN);
  39.                 delay_ms(200);
  40.         }
  41. }

  42. void RCC_Configuration(void)
  43. {
  44.     SystemInit();//72m
  45.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
  46.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);
  47.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);
  48.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE);
  49.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);  
  50.         RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);//使能FSMC接口时钟
  51. }

  52. void GPIO_Configuration(void)
  53. {
  54.     GPIO_InitTypeDef GPIO_InitStructure;        
  55.         
  56.         GPIO_InitStructure.GPIO_Pin=GPIO_Pin_9;//TX
  57.         GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
  58.         GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;
  59.         GPIO_Init(GPIOA,&GPIO_InitStructure);

  60.         GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10;//RX
  61.         GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
  62.         GPIO_Init(GPIOA,&GPIO_InitStructure);

  63.           //FSMC 管脚初始化///////////
  64.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;                //背光控制               
  65.         GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
  66.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//推挽输出
  67.         GPIO_Init(GPIOD, &GPIO_InitStructure);   
  68.         GPIO_SetBits(GPIOD, GPIO_Pin_13);                                //打开背光
  69.                
  70.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;           //TFT 复位脚
  71.         GPIO_Init(GPIOE, &GPIO_InitStructure);   
  72.   
  73.           //启用FSMC复用功能 设置为复用上拉                        
  74.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14  //D0
  75.                                                                 | GPIO_Pin_15  //D1
  76.                                                                 | GPIO_Pin_0   //D2
  77.                                                                 | GPIO_Pin_1   //D3
  78.                                                                 | GPIO_Pin_8   //D13
  79.                                                                 | GPIO_Pin_9   //D14
  80.                                                                 | GPIO_Pin_10 ;//D15                                                                                                                                
  81.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;//复用模式
  82.         GPIO_Init(GPIOD, &GPIO_InitStructure);
  83.         
  84.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7  //D4
  85.                                                                 | GPIO_Pin_8  //D5
  86.                                                                 | GPIO_Pin_9  //D6
  87.                                                                 | GPIO_Pin_10 //D7
  88.                                                                 | GPIO_Pin_11 //D8
  89.                                                                 | GPIO_Pin_12 //D9
  90.                                                                 | GPIO_Pin_13 //D10
  91.                                                                 | GPIO_Pin_14 //D11
  92.                                                                 | GPIO_Pin_15;//D12
  93.         GPIO_Init(GPIOE, &GPIO_InitStructure);         


  94.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 //RS
  95.                                                                 | GPIO_Pin_4  //nOE
  96.                                                                 | GPIO_Pin_5; //nWE
  97.         GPIO_Init(GPIOD, &GPIO_InitStructure);

  98.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; //NE1
  99.         GPIO_Init(GPIOD, &GPIO_InitStructure);
  100. }

  101. void NVIC_Configuration(void)
  102. {
  103.            NVIC_InitTypeDef NVIC_InitStructure;

  104.         NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

  105.         NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
  106.         NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
  107.         NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
  108.         NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  109.         NVIC_Init(&NVIC_InitStructure);
  110. }

  111. void USART_Configuration(void)
  112. {
  113.     USART_InitTypeDef  USART_InitStructure;

  114.         USART_InitStructure.USART_BaudRate=9600;
  115.         USART_InitStructure.USART_WordLength=USART_WordLength_8b;
  116.         USART_InitStructure.USART_StopBits=USART_StopBits_1;
  117.         USART_InitStructure.USART_Parity=USART_Parity_No;
  118.         USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;
  119.         USART_InitStructure.USART_Mode=USART_Mode_Rx|USART_Mode_Tx;

  120.         USART_Init(USART1,&USART_InitStructure);
  121.         USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);
  122.         USART_Cmd(USART1,ENABLE);
  123.         USART_ClearFlag(USART1,USART_FLAG_TC);
  124. }
复制代码

所有资料51hei提供下载:
Keil程序.7z (1.03 MB, 下载次数: 40)



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:860649 发表于 2020-12-15 15:56 | 只看该作者
中间加个液晶控制IC,如RA8889就很好处理了,文字图片甚至视频都很好实现
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表