找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

求助。。困扰了好久的问题啊

[复制链接]
admin 发表于 2012-9-2 14:18:56 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
[pre]就这个程序,让数码管从765432以1/10秒递减至765398为什么写进单片机以后数码管变化的很慢很慢呢???#include <reg52.h>#define uint unsigned long int#define uchar unsigned charsbit dula=P2^6;sbit wela=P2^7;uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};uchar ge,shi,bai,qian,wan,shiwan;uint temp;uchar a;void init1(){ TMOD=0x10; EA=1; ET1=1; TR1=1; TH1=(65536-500)/256; TL1=(65536-500)%256;} void delay(uchar z){ uchar x,y; for(x=z;x>0;x--) for(y=110;y>0;y--) ; }void display(uchar ge,uchar shi,uchar bai,uchar qian,uchar wan,uchar shiwan){ wela=1; P0=0xfe; wela=0; dula=1; P0=table[shiwan]; dula=0; delay(5); wela=1; P0=0xfd; wela=0; dula=1; P0=table[wan]; dula=0; delay(5); wela=1; P0=0xfb; wela=0; dula=1; P0=table[qian]; dula=0; delay(5); wela=1; P0=0xf7; wela=0; dula=1; P0=table[bai]; dula=0; delay(5); wela=1; P0=0xef; wela=0; dula=1; P0=table[shi]; dula=0; delay(5); wela=1; P0=0xdf; wela=0; dula=1; P0=table[ge]; dula=0; delay(5);}void main(){ temp=765432; init1(); while(1) { if(a==20&&temp!=765398) { a=0; temp--; } if(temp==765398) temp=temp; shiwan=temp/100000; wan=(temp%100000)/10000; qian=(temp%100000)%10000/1000; bai=(temp%100000)%10000%1000/100; shi=(temp%100000)%10000%1000%100/10; ge=(temp%100000)%10000%1000%100%10; display(ge,shi,bai,qian,wan,shiwan); }}void timer1() interrupt 3{ TH1=(65536-5000)/256; TL1=(65536-5000)%256; a=a+1;} [/pre]
感激不尽啊!!先谢谢了!
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-25 04:17 , Processed in 0.061768 second(s), 10 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表