亚洲春色中文字幕久久久-三上亚,一吻二脱三床四吻胸,国产真实伦对白视频全集,在线毛片观看,精品成品入口黄网,国产毛aⅴ片久久久,亚洲AV色香蕉一区二区三区老师,萧皇后A级艳片,色情日本视频更新,99久久亚洲精品日本无码
標題:
單片機驅動LCM1604四行液晶例程
[打印本頁]
作者:
IdeaMing
時間:
2021-6-18 14:31
標題:
單片機驅動LCM1604四行液晶例程
51hei圖片_20210618143308.jpg
(4.99 MB, 下載次數: 82)
下載附件
2021-6-18 14:33 上傳
單片機源程序如下:
/* Module---------------------------------------------------------------------*/
#define _MAIN_MODULE_
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private typedef -----------------------------------------------------------*/
#define DATAPORT P0
sbit LCD_RS = P1^0;//0指令 1數據
sbit LCD_RW = P1^1;//0寫 1讀
sbit LCD_EN = P1^2;//使能信號腳
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
code const uint8_t revision_date[12] = __DATE__; //固件生成日期
code const uint8_t revision_time[16] = __TIME__; //固件生成時間
code const uint8_t revision_ver[13]={" Ver:1.0 \r\n"};//版本信息
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
unsigned int time_ms;
unsigned char seg[]={
" LCD1604 Demo "
" By Liming "
" 2021-06-15 "
" PM: --:--:-- "
};
void IO_Init(void)
{
P0M0 = 0x00;P0M1 = 0X00;
P1M0 = 0x07;P1M1 = 0X00;
}
/*******************************************************************************
* @brief None
* @param None
* @retval None
****************************************************************Author:Liming**/
void TIM0_Init(void) //1毫秒@22.1184MHz
{
AUXR |= 0x80; //定時器時鐘1T模式
TMOD &= 0xF0; //設置定時器模式
TL0 = 0x9A; //設置定時初值
TH0 = 0xA9; //設置定時初值
TF0 = 0; //清除TF0標志
ET0 = 1; //定時器0中斷開啟
TR0 = 1; //定時器0開始計時
EA = 1;
}
void TIM0_int (void) interrupt 1
{
if(time_ms>0)time_ms--;
if(task1s)task1s--;
}
void Delay(unsigned int t)
{
time_ms = t;
while(time_ms);
}
uint8_t LCD1604_ReadSta(void)
{
uint8_t res;
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;Delay(5);
res = DATAPORT;
LCD_EN = 0;
return res;
}
void LCD1604_BusyWait(void)
{
/*當P0^7為低電平時,P0口為空閑狀態*/
while((LCD1604_ReadSta()&0x80)==0x80);
Delay(1);
}
void LCD1604_WriteCmd(unsigned char Cmd)
{
LCD1604_BusyWait();
LCD_RS = 0;
LCD_RW = 0;
DATAPORT = Cmd;
LCD_EN = 1;Delay(10);
LCD_EN = 0;
}
void LCD1604_WriteDat(unsigned char Dat)
{
LCD1604_BusyWait();
LCD_RS = 1;
LCD_RW = 0;
DATAPORT = Dat;
LCD_EN = 1;
Delay(10);
LCD_EN = 0;
}
void initial(void){
LCD1604_WriteCmd(0x38);
LCD1604_WriteCmd(0x01);
LCD1604_WriteCmd(0x06);
LCD1604_WriteCmd(0x0c);
}
void main(void){
unsigned char data_index;
unsigned char i;
TIM0_Init(); //SysTick 1ms
initial(); //初始化LCD
while(1){
if(task1s==0)
{
task1s = 1000;sec++;
if(sec>=60){
sec = 0;min++;
if(min>=60){
min = 0;hour++;
if(hour>=12)hour = 0;
}
}
seg[54] = (hour/10)+'0';
seg[55] = (hour%10)+'0';
seg[57] = (min/10)+'0';
seg[58] = (min%10)+'0';
seg[60] = (sec/10)+'0';
seg[61] = (sec%10)+'0';
data_index = 0;
LCD1604_WriteCmd(0x80);//第一行
while(data_index<=15){LCD1604_WriteDat(seg[data_index]);data_index++;}
LCD1604_WriteCmd(0xc0);//第二行
while(data_index<=31){LCD1604_WriteDat(seg[data_index]);data_index++;}
LCD1604_WriteCmd(0x90);//第三行
while(data_index<=47){LCD1604_WriteDat(seg[data_index]);data_index++;}
LCD1604_WriteCmd(0xd0);//第四行
while(data_index<=63){LCD1604_WriteDat(seg[data_index]);data_index++;}
}
}
}
復制代碼
歡迎光臨 (http://www.denmoz.com/bbs/)
Powered by Discuz! X3.1