標(biāo)題:
(海爾)東軟單片機(jī) HR7P153 SOP-16數(shù)碼管顯示程序
[打印本頁(yè)]
作者:
小李子鐵頭
時(shí)間:
2018-9-12 23:51
標(biāo)題:
(海爾)東軟單片機(jī) HR7P153 SOP-16數(shù)碼管顯示程序
HR7P153 SOP-16三個(gè)數(shù)碼管顯示,共陰極。
單片機(jī)源程序如下:
#include <hic.h>
#include <math.h>
#define u8 unsigned char
#define u16 unsigned int
u16 i,a=0;
u8 const SEG7[10]={0x77,0x06,0xb3,0x97,0xc6,0xd5,0xf5,0x07,0xf7,0xd7};
u8 const ACT[3]={0xfb,0xf7,0xef,};
/****************/
void Ram_Clr(void) //ram全清
{
__asm
{
CLR IAAL;
CLR IAAH;
CLR IAD;
INC IAAL,1;
JBS IAAL,6;
GOTO $-3;
}
}
/*****************/
void delay (u16 k)
{
u16 i,j;
for(i=0;i<k;i++)
{
for(j=0;j<100;j++)
{;}
}
}
/***************/
void display(void)
{
PA=SEG7[a%10];
PB=ACT[0];
delay(2);
PA=SEG7[(a%100)/10];
PB=ACT[1];
delay(2);
PA=SEG7[(a/100)%10];
PB=ACT[2];
delay(2);
}
/**************************/
void main()
{
Ram_Clr(); //RAM初始化
OSCP = 0x55; //時(shí)鐘控制寫保護(hù)解鎖
OSCC = 0xf0; //8MHZ
while(!SW_HS); //等待高速時(shí)鐘切換完成
ANS =0xE7; //設(shè)置成數(shù)字輸出
PBT=0x00; //PBT設(shè)置成輸入狀態(tài)
PAT=0x08; ////PAT設(shè)置成輸入狀態(tài)
N_PAU=0x00; //上弱拉
N_PBD=0x00; //下弱拉
while(1)
{
a++;
for(i=250;i>0;i--)
{
display();
}
if(a==100)
{
a=0;
}
}
}
復(fù)制代碼
所有資料51hei提供下載:
數(shù)碼管顯示.rar
(760 Bytes, 下載次數(shù): 33)
2018-9-12 23:50 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
作者:
admin
時(shí)間:
2018-9-13 00:13
樓主您好 能分享原理圖嗎?
作者:
PD3IN1
時(shí)間:
2021-8-17 18:38
牛X,祝你好運(yùn)!
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1