—————————————————————*/
#include <reg51.h>
/*--------------------------------------------
调用方式:自行I/O 口定义﹫2001/05/12
函数说明:私有函数,各接口定义
--------------------------------------------*/
sbit HD7279_CS=P1^4// HD7279_CS--P1.4
sbit HD7279_CLK=P1^5// HD7279_CLK-- P1.5
sbit HD7279_DATA=P1^6// HD7279_DATA-- P1.2
sbit HD7279_KEY =P1^7// HD7279_KEY-- P1.3
/*--------------------------------------------
调用方式: HD7279A 各指令定义﹫2001/05/12
函数说明:私有函数,接口定义
--------------------------------------------*
/#define HD7279_RESET 0xa4 //复位
#define HD7279_TEST 0xbf //测试
#define HD7279_RLC 0xa3 //循环左移
#define HD7279_RRC 0xa2 //循环右移
#define HD7279_RL 0xa1 //左移
#define HD7279_RR 0xa0 //右移
#define HD7279_DECODE0 0x80 //译码方式0
#define HD7279_DECODE1 0xc8 //译码方式1
#define HD7279_UNDECODE 0x90 //译码方式2: 不译码
#define HD7279_HIDE 0x98 //消隐
#define HD7279_FLASH 0x88 //闪烁
#define HD7279_SEGON 0xe0 //段亮
#define HD7279_SEGOFF 0xc0 //段灭
#define HD7279_READ 0x15 //读
/*--------------------------------------------
调用方式: void HD7279_LongDelay(void) 等侍函数﹫2001/05/12
函数说明 私有函数,>500ms
--------------------------------------------*/
void HD7279_LongDelay(void)
{
unsigned char i
for (i=0i<6i++)
}
/*--------------------------------------------
调用方式:void HD7279_ShortDelay(void) 等侍函数﹫2001/05/12
函数说明:私有函数,=500ms
--------------------------------------------*
/void HD7279_ShortDelay(void)
{}
/*--------------------------------------------
调用方式:void Delay10ms(unsigned char time) 等侍函数﹫2001/05/12
函数说明:私有函数, 6M晶振
--------------------------------------------*/
void Delay10ms(unsigned char time)
{
unsigned char i
unsigned int j
for(i=0i<timei++)
{
for(j=0j<931j++)
{}
}
}
/*--------------------------------------------
调用方式:void HD7279_ShortDelay(void) 函数﹫2001/05/12
函数说明:私有函数,送指令
--------------------------------------------*/
void HD7279_SendByte( unsigned char out_byte)
{
unsigned char i
HD7279_CS=0
HD7279_LongDelay()
for(i=0i<8i++)
{
if(out_byte&0x80) { HD7279_DATA=1}
else { HD7279_DATA=0}
HD7279_CLK=1
HD7279_ShortDelay()
HD7279_CLK=0
HD7279_ShortDelay()
out_byte=out_byte<<1
}
HD7279_DATA=0
}
/*--------------------------------------------
调用方式:void Write7279(unsigned char command,unsigned char dta) 函数﹫2001/05/12
函数说明:私有函数,写函数
--------------------------------------------*/
void Write7279(unsigned char command, unsigned char dta)
{
HD7279_SendByte( command )
HD7279_SendByte( dta )
}
/*--------------------------------------------
调用方式:自定义函数﹫2001/05/12
函数说明:私有函数,自行定义
--------------------------------------------*/
#define RunKey 0xXX
#define StopKey 0xXX
/*--------------------------------------------
调用方式:unsigned charHD7279_ReceiveByte(void)函数﹫2001/05/12
函数说明:私有函数,接受一个BYTE函数
--------------------------------------------*/
unsigned char HD7279_ReceiveByte(void)
{
unsigned char i, in_byte
HD7279_DATA=1
HD7279_LongDelay()
for(i=0i<8i++)
{HD7279_CLK=1<br>HD7279_ShortDelay()<br>in_byte=in_byte<<1<br>if(HD7279_DATA) { in_byte=in_byte|0x01}
HD7279_CLK=0
HD7279_ShortDelay()
}
HD7279_DATA=0
return (in_byte)
}
/*--------------------------------------------
调用方式:unsigned char HD7279_GetKey()函数﹫2001/05/12
函数说明:私有函数,读键盘函数
--------------------------------------------*/
unsigned char HD7279_GetKey()
{
unsigned char key
if(!HD7279_KEY)
{
HD7279_SendByte(HD7279_READ)
key=HD7279_ReceiveByte()
switch( key )
{case RunKey: <br>case StopKey: <br>while(!HD7279_KEY)<br>default: return(0xff)<br>}
}
return(0xff)
}
/*--------------------------------------------
调用方式:main()函数﹫2001/05/12
函数说明:私有函数,例函数
--------------------------------------------*/
main()
{HD7279_SendByte(0xa4)//复位<br>Write7279(0x80,0)//显示‘0’<br>}
The diesel engine fuel oil consumption rate weighs the diesel engine itself fuel oil efficient most important target.Also is the diesel engine performance important technical parameter, the diesel engine fuel oil consumption rate tradition measuring technique cannot carry on the survey under the ships navigation condition.Therefore sought with the software establishment survey oil consumption meter procedure innovation method had the theory and practical significancethis article introduced introduced the monolithic integrated circuit development general picture and the MCS-96 monolithic integrated circuit performance characteristic, and has carried on controls the chip take 80C196KC, as assisted the chip take 74 series, fixed time counted take the double-current gauge as the measuring technique diesel engine fuel oil consumption software the procedure and the HD7279A test order establishment.
In has completed in the software fixed time procedure foundation, has discussed, how enhances the development entire procedure the working efficiency, with monolithic integrated circuit performance method.And has completed the program debugging and the modelling.The experiment indicated that, the C language procedure may enhance the entire procedure effectively the working efficiency, moreover is helpful to fully displays the performance which the monolithic integrated circuit processor enhances day by day
给你个参考吧,T1是显示控制,消隐时间由T1初值决定一般5毫秒左右就可以了。KEYVAL EQU 30H
DAT EQU 33H
SCANLED EQU 39H
CLK EQU 77H
SEC EQU 78H
SEC1 EQU 79H
SEC2 EQU 7AH
DOT BIT 00H
ORG 0000H
LJMP MAIN
ORG 0003H
LJMP EXTINT0
ORG 000BH
LJMP T0ISR 50ms定时
ORG 001BH
LJMP T1ISR 扫描显示
ORG 0030H
MAIN:
MOV SP,#5FH
MOV TMOD,#11H
MOV TH0,#03CH
MOV TL0,#0B0H
MOV TH1,#0ECH
MOV TL1,#078H
MOV KEYVAL,#0FFH
MOV 33H,#10H
MOV 34H,#10H
MOV 35H,#10H
MOV 36H,#10H
MOV SEC,#0
MOV SEC1,#0
MOV SEC2,#0
MOV CLK,#0
SETB IT0
SETB EX0
CLR TR0
CLR ET0
SETB TR1
SETB ET1
SETB EA
LOOP:
MOV A,KEYVAL
LOOP1:
JNZ LOOP2 启动
SETB TR0
SETB ET0
SJMP LOOP
LOOP2:
DEC A
JNZ LOOP3 暂停
CLR TR0
CLR ET0
SJMP LOOP
LOOP3:
DEC A
JNZ LOOP4 清零
MOV SEC,#0
MOV SEC1,#0
MOV SEC2,#0
LCALL DISCHG
SJMP LOOP
LOOP4:
可以在此扩展想要的功能
SJMP LOOP
------------------
十六进制转换为BCD
HBCD:
MOV B,#10
DIV AB
SWAP A
ORL A,B
RET
--------------------
DELAY:
MOV R3,#50
DELAY1:
MOV R4,#100
DJNZ R4,$
DJNZ R3,DELAY1
DJNZ R2,DELAY
RET
--------------------
EXTINT0:
PUSH ACC
INC KEYVAL
MOV A,KEYVAL
CJNE A,#3,EXT00
EXT00:
JC EXT01
MOV KEYVAL,#0
EXT01:
POP ACC
RETI
--------------------
T0ISR:
PUSH ACC
CLR TR0
MOV TH0,#3CH
MOV TL0,#0B0H
SETB TR0
INC CLK
MOV A,CLK
CJNE A,#2,T0ISRE
MOV CLK,#0
INC SEC1
MOV A,SEC1
CJNE A,#100,T0ISRE
MOV SEC1,#0
INC SEC2
MOV A,SEC2
CJNE A,#100,T0ISRE
MOV SEC,#0
MOV SEC1,#0
MOV SEC2,#0
T0ISRE:
LCALL DISCHG
POP ACC
RETI
--------------------
DISCHG:
MOV A,SEC1
LCALL HBCD
PUSH ACC
ANL A,#0FH
MOV 36H,A
POP ACC
ANL A,#0F0H
SWAP A
MOV 35H,A
MOV A,SEC2
LCALL HBCD
PUSH ACC
ANL A,#0FH
MOV 34H,A
POP ACC
ANL A,#0F0H
SWAP A
MOV 33H,A
RET
--------------------
T1ISR:
PUSH ACC
CLR TR1
MOV TH1,#0ECH
MOV TL1,#78H
SETB TR1
MOV DPTR,#LEDTAB
T100:
MOV R0,#DAT
MOV A,SCANLED
ADD A,R0
MOV R0,A
MOV A,SCANLED
JNZ T101
MOV P2,#01H
CLR DOT
SJMP T1DIS
T101:
DEC A
JNZ T102
MOV P2,#02H
CLR DOT
SJMP T1DIS
T102:
DEC A
JNZ T103
MOV P2,#04H
SETB DOT
SJMP T1DIS
T103:
DEC A
JNZ T1DIS
MOV P2,#08H
CLR DOT
T1DIS:
MOV A,@R0
MOVC A,@A+DPTR
JNB DOT,T1DIS1
ORL A,#01H
T1DIS1:
CPL A
MOV P0,A
INC SCANLED
MOV A,SCANLED
CJNE A,#4,T1END
MOV SCANLED,#0
T1END:
POP ACC
RETI
--------------------
LEDTAB: DB 0FCH "0" 00H
DB 60H "1" 01H
DB 0DAH "2" 02H
DB 0F2H "3" 03H
DB 66H "4" 04H
DB 0B6H "5" 05H
DB 0BEH "6" 06H
DB 0E0H "7" 07H
DB 0FEH "8" 08H
DB 0F6H "9" 09H
DB 0EEH "A" 0AH
DB 3EH "B" 0BH
DB 9CH "C" 0CH
DB 7AH "D" 0DH
DB 9EH "E" 0EH
DB 8EH "F" 0FH
DB 00H " " 10H
--------------------
END
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)