-
大小: 58KB文件類型: .rar金幣: 2下載: 1 次發(fā)布日期: 2021-06-19
- 語言: 其他
- 標(biāo)簽:
資源簡介
很好的源代碼,ATT7022計(jì)量芯片,C編程,很好用,希望大家喜歡

代碼片段和文件信息
#include
#include
#include
#include
///////////////////頭文件包含/////////////////////
//////////////////////////////////////////////////
#define?uchar?unsigned?char
#define?uint?unsigned?int
/////////////////////////////////////////////////
uchar?table[]={“welcome?to?use飫趐lease?wait.........“};
uchar?tablea[]={“校正中......please?wait“};
uchar?tableb[]={“校正完畢please?choose“};
uchar?tablec[]={“丈量中......please?wait“};
uchar?tablee[]={“丈量完畢please?choose“};
uchar?tablef[]={“please?insert?your?password“};
void?delay(uint?ms)//通用延時(shí)函數(shù),8M外部晶振下,延時(shí)nms
{
uint?ij;
for(i=0;i
for(j=0;j<1141;j++);
}
///////////////下面是用于128*64液晶顯示的子程序///////////////
#define?RS?(1<<4)
#define?RW?(1<<5)
#define?EN?(1<<6)
void?s_ms(uint?ms)//用于液晶的延時(shí)函數(shù)
{
for(;ms>1;ms--);
}
//寫數(shù)據(jù)
void?WriteDataLCM(unsigned?char?WDLCM)
{
s_ms(100);
PORTA|=RS;//RS=1
s_ms(100);
PORTA&=~RW;//RW=0
s_ms(100);
PORTA|=EN;//EN=1
s_ms(100);
PORTB=WDLCM;//輸出數(shù)據(jù)
s_ms(100);
PORTA&=~EN;//EN=0
s_ms(100);
}
//寫指令
void?WriteCommandLCM(unsigned?char?WCLCM)
{
s_ms(100);
PORTA&=~RS;//RS=0
s_ms(100);
PORTA&=~RW;//RW=0
s_ms(100);
PORTA|=EN;//EN=1
s_ms(100);
?PORTB=WCLCM;//輸出指令
s_ms(100);
PORTA&=~EN;//EN=0
s_ms(100);
}
void?LCMInit(void)//液晶初始化
{
DDRB=0XFF;
DDRA=0XFF;//數(shù)據(jù)口于液晶控制口配置為輸出
WriteCommandLCM(0x38);//三次顯示模式設(shè)置,不檢測忙信號
s_ms(1000);
WriteCommandLCM(0x38);
s_ms(1000);
WriteCommandLCM(0x38);
s_ms(1000);
WriteCommandLCM(0x38);//顯示模式設(shè)置開始要求每次檢測忙信號
WriteCommandLCM(0x08);//封閉顯示
WriteCommandLCM(0x01);//顯示清屏
WriteCommandLCM(0x06);//顯示光標(biāo)移動設(shè)置
WriteCommandLCM(0x0C);//顯示開及光標(biāo)設(shè)置
}
void?sz(unsigned?long?int?szchar?adresschar?i)//指定地址并且顯示八位數(shù)字
{
char?j;
char?shuma[8];
shuma[0]=sz%10;//最低位
shuma[1]=sz/10%10;
shuma[2]=sz/10/10%10;
shuma[3]=sz/10/10/10%10;
shuma[4]=sz/10/10/10/10%10;
shuma[5]=sz/10/10/10/10/10%10;
shuma[6]=sz/10/10/10/10/10/10%10;
shuma[7]=sz/10/10/10/10/10/10/10%10;//最高位
WriteCommandLCM(adress);//寫進(jìn)數(shù)據(jù)顯示地址
delay(1);
for(j=8;j--;j>=0)
{
if(j==(i-1))
{
WriteDataLCM(0x2e);
delay(1);
}
WriteDataLCM(0X30+shuma[j]);
//delay(1);
}
}
///////////////液晶顯示函數(shù)結(jié)束///////////////////////
///////////////矩陣鍵盤掃描檢測函數(shù)///////////////////
/////由于硬鍵盤接口接上軟鍵盤后不能用,矩陣按鍵子程序重新編寫,無消抖檢測///////
uchar?key_value(void)
{
uchar?key;
char?tem1tem2remi;
rem=0;//不清零會返回一個(gè)不可預(yù)知的值
DDRD=0x0f;//D口高四位輸出低四位輸進(jìn)
PORTD=0xf0;//輸進(jìn)有上拉電阻輸出低電平
s_ms(1);
tem1=PIND;//讀取端口D
tem1=tem1&0xf0;
if(tem1!=0xf0)//判定是否有鍵被按下
{
s_ms(200);//延時(shí)
tem2=PIND;//讀取端口D
tem2=tem2&0xf0;
if(tem1==tem2)//判定是否為干擾
{
DDRD=0xf0;//D口高四位輸進(jìn)低四位輸出
PORTD=0x0f;//反相輸出
s_ms(50);//換向后要延時(shí)
rem=PIND;//讀取端口D
rem=rem&0x0f;//取高四位
rem=rem+tem1;//合并
rem=~rem;//反向輸出
}
}
key=rem;
switch(key)
{
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????14775??2010-11-17?20:21??ATT7022電能計(jì)量程序\diannengjiliang.c
?????文件??????????0??2010-11-17?20:43??ATT7022電能計(jì)量程序\diannengjiliang.cof
?????文件????????114??2010-11-17?20:43??ATT7022電能計(jì)量程序\diannengjiliang.dp2
?????文件??????????0??2010-11-17?20:43??ATT7022電能計(jì)量程序\diannengjiliang.hex
?????文件??????????0??2010-11-17?20:43??ATT7022電能計(jì)量程序\diannengjiliang.i
?????文件?????283473??2010-11-17?20:22??ATT7022電能計(jì)量程序\diannengjiliang.lis
?????文件?????????20??2010-11-17?20:43??ATT7022電能計(jì)量程序\diannengjiliang.lk
?????文件????????569??2010-11-17?20:43??ATT7022電能計(jì)量程序\diannengjiliang.mak
?????文件??????76873??2010-11-17?20:22??ATT7022電能計(jì)量程序\diannengjiliang.o
?????文件????????883??2010-11-17?20:43??ATT7022電能計(jì)量程序\diannengjiliang.prj
?????文件?????109847??2010-11-17?20:22??ATT7022電能計(jì)量程序\diannengjiliang.s
?????文件?????????52??2010-11-17?20:20??ATT7022電能計(jì)量程序\DIANNENGJILIANG.SRC
?????文件??????????2??2010-11-17?20:20??ATT7022電能計(jì)量程序\diannengjiliang._c
?????目錄??????????0??2010-11-17?20:43??ATT7022電能計(jì)量程序
-----------?---------??----------?-----??----
???????????????486608????????????????????14
評論
共有 條評論