15年0个月前IP:未同步
347754
2楼
数码管利用状态标记+程序流程上的占用代替,亮度保护保持时间,提升运行效率.

#include<reg52.h>
#define uchar unsigned char
#define uint  unsigned int
sbit w1=P2^4;
sbit w2=P2^5;
sbit w3=P2^6;
sbit w4=P2^7;
unsigned int bbb,aaa,smg,ccc;
uchar code table[]={0x28,0xeb,0x32,0xa2,0xe1,0xa4,0x24,0xea,0x20,0xa0,0xff};
void delay()
{
   for(bbb=0;bbb<250;bbb++)
  {
;
}
}
void smg_xs()
{
smg++;
if(smg==5)
{
smg=1;
}
if(smg==1)
{
w2=w3=w4=1;
P0=table[aaa%10];
w1=0;
}
if(smg==2)
{
w1=w3=w4=1;
P0=table[aaa/10%10];
w2=0;
}
if(smg==3)
{
w1=w2=w4=1;
P0=table[aaa/100%10];
w3=0;
}
if(smg==4)
{
w1=w2=w3=1;
P0=table[aaa/1000%10];
w4=0;
}
}
void main()
{
smg=0;
aaa=1234;
ccc=0;
while(1)
{
smg_xs();
delay();
delay();//#%%%¥#%¥@%@¥#%#@
ccc++;
if(ccc>30)
{
ccc=0;
aaa++;
}
if(aaa>9999)
{
aaa=0;
}
}
}



delay(10);
估计要是10ms 的话 因当消耗了 10000个左右的指令周期 ,  以上程序着是利用上这些时间,处理其它任务,在加上自己的循环
评论
文号 / 347754

千古风流
名片发私信
学术分 4
总主题 494 帖总回复 6744 楼拥有证书:学者 笔友
注册于 2009/01/02 22:19:00最后登录 2018/01/10 01:36:08
主体类型:个人
所属领域:无
认证方式:邮箱
IP归属地:0

个人简介

.

笔记
{{note.content}}
{{n.user.username}}
{{fromNow(n.toc)}} {{n.status === noteStatus.disabled ? "已屏蔽" : ""}} {{n.status === noteStatus.unknown ? "正在审核" : ""}} {{n.status === noteStatus.deleted ? '已删除' : ''}}
  • 编辑
  • 删除
  • {{n.status === 'disabled' ? "解除屏蔽" : "屏蔽" }}
我也是有底线的