|
LCD1602A第一行顯示信息加學(xué)號(hào)滾動(dòng)顯示,第二行顯示倒計(jì)時(shí)40s,晶振11.0952MHz,程序似乎是沒(méi)什么問(wèn)題,proteus仿真也是好的,但是我下載到開(kāi)發(fā)板以后就只有第一行的滾動(dòng)顯示,而沒(méi)有第二行的倒計(jì)時(shí),為什么啊?用的是YL-51單片機(jī),請(qǐng)大家看看我的程序和仿真圖。我是新手,好多地方都不太懂,求指教!
單片機(jī)源程序如下:
#include <REGX51.H>
#include <string.h>
#define uint unsigned int
#define uchar unsigned char
sbit RS=P3^5;
sbit RW=P3^6;
sbit EN=P3^4;
unsigned char i,q=0,w=0,e=0,x=0,c=40;
unsigned char xuehao1[]="LGL1605230139";
unsigned char xuehao2[]="ZCY1605230140";
unsigned char xuehao3[]="SGJ1605230126";
unsigned char xuehao4[]="XWQ1605230124";
unsigned char code num[]={0X30,0X31,0X32,0X33,0X34,0X35,0X36,0X37,0X38,0X39};
void delay(int n)
{
int j,k;
for(k=0;k<n;k++)
{
for(j=0;j<200;j++);
}
}
void timer0()
{
TMOD=0X01;
TH0=(65536-9216)/256;
TL0=(65536-9216)%256;
EA=1;
ET0=1;
TR0=1;
}
void LCD1602_write_cmd(unsigned char cmd)
{
P0=cmd;
RS=0;
RW=0;
EN=1;
EN=0;
delay(10);
}
void LCD1602_write_Data(unsigned char Data)
{
P0=Data;
RS=1;
RW=0;
EN=1;
EN=0;
delay(10);
}
void LCD1602_init()
{
LCD1602_write_cmd(0x38);
LCD1602_write_cmd(0x0C);
LCD1602_write_cmd(0x06);
LCD1602_write_cmd(0x01);
}
void disp_LCD(uint c)
{
LCD1602_write_cmd(0xC0);
LCD1602_write_Data(num[c/10]);
LCD1602_write_cmd(0XC1);
LCD1602_write_Data(num[c%10]);
}
void disp_XXLCD()
{
LCD1602_write_cmd(0X80);
for(w=e;w<13+e;w++)
{
LCD1602_write_Data(xuehao1[w]);
}
e++;
if(e>=45)
{
e=0;
delay(200);
}
delay(60);
}
void main()
{
timer0();
LCD1602_init();
while(1)
{
disp_XXLCD();
disp_LCD(c);
if(c==0)
while(1);
}
}
void timer() interrupt 1
{
TH0=(65536-9216)/256;
TL0=(65536-9216)%256;
x++;
if(x==100)
{
x=0;
c--;
}
}
這個(gè)是我的程序,另外我的這個(gè)設(shè)計(jì),倒計(jì)時(shí)的時(shí)候好像因?yàn)榍懊娴娘@示程序需要的時(shí)間太長(zhǎng),后邊的倒計(jì)時(shí)不是一秒,而是一秒多,這個(gè)問(wèn)題該怎么解決呢?最重要的是怎么解決開(kāi)發(fā)板第二行不顯示的問(wèn)題
|
-
-
|