STM32F1x系列——12864
来源:互联网 发布:百度网盘旧版 mac 编辑:程序博客网 时间:2024/06/08 03:20
12864的引脚图:
由图可知PSB一开始要拉高,可以接到电源上,VCC接5v电源,VSS接地,要是12864产生背光,将BLA接5v电源,BLK接地。其余引脚可以自定义接到STM32的IO上。
在接STM32的IO后,程序中应首先要对IO进行初始化,进行端口使能等操作,12864有其自带的中文字库,在程序中对字库初始化,同时写好传送数据指令的函数,输出显示内容,下面是关于12864的代码:
#include "stm32f10x.h"#include "delay.h"#include "stm32f10x_gpio.h"#define V0 PCout(1)#define RS PCout(3)#define WRD PAout(8)#define E PAout(9)#define DB0 PAout(0)#define DB1 PAout(1)#define DB2 PAout(2)#define DB3 PAout(3)#define DB4 PAout(4)#define DB5 PAout(5)#define DB6 PAout(6)#define DB7 PAout(7)#define NC PEout(10)#define RES PEout(12)#define VOUT PBout(14)void _Init(void){ GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOE, ENABLE); //使能PB,PE端口时钟 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4|GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9; //LED0-->PB.5 端口配置 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度为50MHz GPIO_Init(GPIOA, &GPIO_InitStructure); //根据设定参数初始化GPIOA GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1|GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOE, &GPIO_InitStructure); }unsigned int temp ;void TransferData(char data1,unsigned char DI) //传送数据或者命令,当DI=0是,传送命令,当DI=1,传送数据.{WRD=0;RS=DI;delay_ms(1);temp = (temp&0xff00)|data1 ;GPIO_Write(GPIOA,temp) ;E=1;delay_ms(1);E=0; } void initinal(void) //LCD字库初始化程序{ delay_ms(40); RES=0; //复位 delay_ms(1); RES=1; //复位置高 delay_ms(10); TransferData(0x30,0); //Extended Function Set :8BIT设置,RE=0: basic instruction set, G=0 :graphic display OFF delay_ms(100); TransferData(0x30,0); //Function Set delay_ms(37); TransferData(0x08,0); //Display on Control delay_ms(100); TransferData(0x10,0); //Cursor Display Control光标设置 delay_ms(100); TransferData(0x0C,0); //Display Control,D=1,显示开 delay_ms(100); TransferData(0x01,0); //Display Clear delay_ms(10); TransferData(0x06,0); //Enry Mode Set,光标从右向左加1位移动 delay_ms(100); }void lcd_mesg(unsigned char *adder1 ,unsigned char locate,unsigned int number){ unsigned char i; TransferData(locate,0); //Set Graphic Display RAM Address delay_ms(100); for(i=0;i<number;i++) { TransferData(*adder1,1); adder1++; }} int main(void) { delay_init(); _Init(); initinal() ; while(1) { lcd_mesg("日照香炉生紫烟,",0x80,16) ; lcd_mesg("遥看瀑布挂前川。",0x90,16) ; lcd_mesg("飞流直下三千尺,",0x88,16) ; lcd_mesg("疑是银河落九天。",0x98,16) ; // TransferData(0x01,0) ; //清屏 } }
仿真下载后:
阅读全文
0 0
- STM32F1x系列——12864
- STM32F1x系列——GPIO操作
- STM32F1x系列——按键输入实验
- STM32F1x系列——串口通信
- STM32F1x系列——外部中断
- STM32F1x系列——定时器中断
- STM32F1x系列——Flash 模拟 EEPROM
- STM32F1x系列——跑马灯实验-库函数
- STM32F1x 逆向工程初步
- Git系列三——系列总结
- 【J2EE系列】—Servlet
- RxJava—Subject系列
- Linq系列—简介
- Linq系列—泛型
- Linq系列—委托
- Binder系列—开篇
- SpringBoot系列—概述
- Ubuntu13.04使用Jlink和ST-Link V2烧写STM32F1x和STM32F4x
- 在一个页面使用多个 kindeditor编辑器
- LeetCode 59. Spiral Matrix II
- vue项目生产模式构建
- Redis——基础1
- 局外人的激情
- STM32F1x系列——12864
- 像input,button等元素对齐方法
- block的使用
- linux权限随笔
- Webrtc 动态分辨率
- (牛客网)栈的压入、弹出序列
- Python安装和PyCharm(2017.1.3)安装、注册、汉化教程
- js 模拟表单post方式提交
- PhpExcel导出excel 配置缓存