⑴ 51单片机完成简易秒表的设计
硬件电路简单,我说下软件部分
用一个定时器定时中断做键盘扫描,数码管用动态扫描的方法,数码管显示和按键处理都放在主程序中进行
⑵ 如何用单片机汇编语言设计一个秒表
C51 http://..com/question/42921479.html?fr=qrl&cid=192&index=1
http://..com/question/29519178.html?fr=qrl&cid=192&index=2
1.基于单片机的设计
2.计时精度:百分之一秒
2.5键操作完成 清除 启动 停止 设置初值 程序退出的功能
采用LED显示时、分、秒、百分之一.PROTEL图最好也有
用89C51,外接晶振,复位电路,二个数码管,二个按键,做一个电子秒表,具体要求为用按键起停电子表,可用按键设计倒计时时间(如10S,20S,60S),并启动倒计时功能。能用按键选择以上两功能之一。
三、程序代码:
A_BIT EQU 20H
B_BIT EQU 21H
TEMP EQU 22H
MOV P3,#0FFH
MOV P0,#0FFH
CLR F0
CLR F1
MOV DPTR,#NUMTAB
MOV P3,#0FFH
MOV P0,#0FFH
START:JB P3.6,START1
ACALL DELAY10
JB P3.6,START
JNB P3.6,$
LJMP GN1
START1: JB P3.7,START
ACALL DELAY10
JB P3.7,START1
JNB P3.7,$
LJMP GN2
GN1:
S1:MOV A,#0
MOV TEMP,A
GOON1: MOV R2,#2
JS1: MOV R3,#250
TIME1: MOV A,TEMP
MOV B,#10
DIV AB
MOV B_BIT,A
MOV A_BIT,B
LCALL DPLOP1
C1: JB P3.6,B1
ACALL DELAY10
JB P3.6,C1
JNB P3.6,$
CPL F0
ZT1: ; MOV P3,#0FFH
JB P3.6,$
ACALL DELAY10
JB P3.6,ZT1
JNB P3.6,$
LCALL DPLOP1
B1: JB P3.7,LOOP1
ACALL DELAY10
JB P3.7,B1
JNB P3.7,$
AJMP OVER
LOOP1: DJNZ R3,TIME1
DJNZ R2,JS1
INC TEMP
MOV A,TEMP
CLR C
SUBB A,#60
JNZ GOON1
ACALL OVER
RET
GN2: MOV A,#14H
MOV TEMP,A
MOV P3,#0FFH
MOV P0,#14H
GOON2: MOV R2,#2
JS2: MOV R3,#250
TIME2: MOV A,TEMP
MOV B,#10
DIV AB
MOV B_BIT,A
MOV A_BIT,B
MOV DPTR,#NUMTAB
DPLOP2: MOV A,A_BIT
MOVC A,@A+DPTR
MOV P0,A
CLR P2.5
ACALL DELY1
SETB P2.5
MOV A,B_BIT
MOVC A,@A+DPTR
MOV P0,A
CLR P2.6
ACALL DELY1
SETB P2.6
C2: JB P3.6,B2
ACALL DELAY10
JB P3.6,C2
JNB P3.6,$
ZT2: MOV P3,#0FFH
JB P3.6,$
ACALL DELAY10
JB P3.6,ZT2
JNB P3.6,$
B2: JB P3.7,LOOP2
ACALL DELAY10
JB P3.7,B1
JNB P3.7,$
AJMP OVER
LOOP2: DJNZ R3,TIME2
DJNZ R2,JS2
DEC TEMP
MOV A,TEMP
JNZ GOON2
ACALL OVER
RET
OVER: AJMP START
DELY1: MOV R4,#2
D1:MOV R5,#248
DJNZ R5,$
DJNZ R4,D1
RET
DELAY10: MOV R4,#20
D2:MOV R5,#248
DJNZ R5,$
DJNZ R4,D2
RET
NUMTAB: DB 40H,79H,24H,30H,19H,12H,02H,78H,00H,10H
DPLOP1: MOV A,A_BIT
MOVC A,@A+DPTR
MOV P0,A
CLR P2.5
ACALL DELY1
SETB P2.5
MOV A,B_BIT
MOVC A,@A+DPTR
MOV P0,A
CLR P2.6
ACALL DELY1
SETB P2.6
RET
END
⑶ 单片机秒表设计(含按键,中断,定时器等)
#include<reg52.h>
#define uint unsigned int
/*int code table[]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,
0x82,0xF8,0x80,0x90,0x88,0x83,
0xC6,0xA1,0x84,0x0E};*/
/*uint code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uint num=0,aa=0,,shi,ge;
void display(uint ,shi,ge);//数码管位显示子函数
void init(); //定时器子函数
void delay(uint z); //延时子函数
void main()
{
init();//初始化定时器
while(1)
{
if(aa==20)
{
aa=0;
num++;
if(num==100)num=0;
=num/100;
shi=num%100/10;
ge=num%10;
}
display(,shi,ge);
}
}
void display(uint ,shi,ge)
{
P1=0xfe;
P0=table[];
delay(5);
P1=0xfd;
P0=table[shi];
delay(5);
P1=0xfb;
P0=table[ge];
delay(5);
}
void timer0() interrupt 1
{
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
aa++;
}
void init()
{
TMOD=1;
TH0=(65535-50000)/256;
TL0=(65535-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
void delay(uint z)
{
uint a,b;
for(a=z;a>0;a--)
for(b=110;b>0;b--);
}*/
⑷ 基于单片机的多功能秒表设计,有什么重难点呢
按下按键时,TR0=0 TR1=0 即可
显示程序不要放在定时器中断程序里,定时器中断程序只负责更新时间
数码管的刷新放在主程序中,这样不管时间是否走动,数码 管一直显示
⑸ 单片机课程设计 秒表设计
#include<reg51.h>#include<stdio.h>#define dat P0
#define uchar unsigned char#define uint unsigned int
sbit seg1 = P2^0;sbit seg2 = P2^1;sbit seg3 = P2^2;sbit seg4 = P2^3;
uchar a,b,c,d;uint timeout=0,us=0,ms=0;uchar code table[]={0xC0,0xF9,0xA4,0xB0, 0x99,0x92,0x82,0xF8, 0x80,0x90,0x88,0x83, 0xC6,0xA1,0x86,0x8E}; //共阳
/*uchar code table[]={0x3f,0x06,0x5b,0x4f, //0~3 0x66,0x6d,0x7d,0x07, //4~7 0x7f,0x6f,0x77,0x7c, //8~b 0x39,0x5e,0x79,0x71}; //共阴 */
void delay(uint z){while(z--);}
void display(){ dat = table[a]; seg1 = 0; delay(1000); seg1 = 1; dat = 0xff; dat = table[b]-0x80; seg2 = 0; delay(1000); seg2 = 1; dat = 0xff; dat = table[c]; seg3 = 0; delay(1000); seg3 = 1; dat = 0xff; dat = table[d]; seg4 = 0; delay(1000); seg4 = 1; dat = 0xff; }
void InitTimer0(void){ TMOD = 0x01; TH0 = (65536-10000)/256; TL0 = (65536-10000)%256; EA = 1; ET0 = 1; TR0 = 1;}
void main(void){ InitTimer0(); while(1) { d = us%10; c = us/10; b = ms%10; a = ms/10; display(); }}
void Timer0Interrupt(void) interrupt 1{ TH0 = (65536-10000)/256; TL0 = (65536-10000)%256; //add your code here! timeout++; if(timeout==1) { timeout = 0; us++; if(us==100) { us = 0; ms++; { if(ms==100) { ms = 0; } } } }}
⑹ 单片机课程设计电子秒表
电路原理图已画好
实现你描述的全部功能
KeiluVision3编译通过,C语言编写,有详细注释
实机调试通过
留个邮箱发给你...
----------------------------
邮件已发......
⑺ 单片机秒表设计
用AT89C51设计一个2位的LED数码显示作为“秒表”,这应该是一个仿真题,可用两位一体的共阴数码管,用定时器T0定时,得到1秒计时。
⑻ 单片机秒表设计系统的构成及功能
单片机的秒表设计系统的构成的话,一般是通过单片机的的士气去设置的,例如我们设置的单片机的定时器是一毫秒,那么每一个一一毫秒的加一这样的话,通过不断的增加,然后去获得时间的
⑼ 51单片机 秒表设计
// 51单片机 秒表,显示时间为0000—9999秒,启动、停止,(停止后再次启动复位)
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar ,shi;
uint a1,a2;
sbit D1=P3^0;
sbit D2=P3^1;
sbit D3=P3^2;
sbit D4=P3^3;
sbit key=P3^5;
sbit key1=P3^7;
bit j ;
uint y ;
void main()
{
TMOD=0x01;
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
EA=1;
ET0=1;
TR0=1;
=0;
shi=0;
while(1)
{
if(key==0)
{
j=0;
}
if(key1==0)
{
j=1; a2=0;
}
}
}
void timer0()interrupt 1
{
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
a1++;
y++;
if(a1==100)
{
a1=0;
if(j==1) a2++;
if(a2>=10000) a2=0;
}
D1 = 1; D2 = 1; D3 = 1; D4 = 1;
if(y==1)
{
P1=table[a2%10000/1000];
D4=0;
}
if(y==2)
{
P1=table[a2%1000/100];
D3=0;
}
if(y==3)
{
P1=table[a2%100/10];
D2=0;
}
if(y==4)
{
P1=table[a2%10];
D1=0;
y=0;
}
}