標題:
STM32F103單片機的LCD12864程序 親測可用
[打印本頁]
作者:
wliuxiaoxiaow
時間:
2022-4-1 22:02
標題:
STM32F103單片機的LCD12864程序 親測可用
STM32F103ZET6并行驅(qū)動LCD12864的程序,親測可用
單片機源程序如下:
#include "lcd.h"
#include "sys.h"
#include "delay.h"
u16 temp;
void IO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOC,ENABLE);
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOC,&GPIO_InitStructure);
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_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure);
}
//LCD初始化
void LCD_Init()
{
LCD_wcmd(0x30);//功能設(shè)定:基本指令集
delay_ms(5);
LCD_wcmd(0x0C);//顯示開,關(guān)光標
delay_ms(5);
LCD_wcmd(0x01);//清除顯示
}
//忙判斷
void CheckBusy(void)
{
u8 status;
RS=0;
RW=1;
GPIOA->ODR = 0xFF;//和這個有什么關(guān)系??
do
{
EN = 1;
delay_ms(5);
status = GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_7);//判斷BF位
}while(status & 0x80);
EN=0;
}
//LCD寫命令
void LCD_wcmd(u8 cmd)
{
CheckBusy();
RS=0;
RW=0;
delay_ms(5);
temp=(temp&0xff00)|cmd;
GPIO_Write(GPIOA,temp);
EN=1;
delay_ms(10);
EN=0;
}
//LCD寫數(shù)據(jù)
void LCD_wdat(u8 dat)
{
CheckBusy();
RS=1;
RW=0;
delay_ms(5);
temp=(temp&0xff00)|dat;
GPIO_Write(GPIOA,temp);
EN=1;
delay_ms(10);
EN=0;
}
//向LCD12864中寫入一行數(shù)據(jù)
void LCD_Wmessage(u8* message,u8 address)
{
LCD_wcmd(address);//要顯示的位置
while(*message>0)//這個判斷很關(guān)鍵
{
LCD_wdat(*message);
message++;
}
}
復(fù)制代碼
Keil代碼下載:
代碼.7z
(186.01 KB, 下載次數(shù): 84)
2022-4-3 02:18 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
cdh98mail
時間:
2022-10-17 18:21
這個就是正點原子的例子程序,完全沒有必要下
作者:
cdh98mail
時間:
2022-10-17 18:22
這個就是正點原子的例子程序,沒有必要下載。
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1