完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include
***it ADDR0 = P1^0; ***it ADDR1 = P1^1; ***it ADDR2 = P1^2; ***it ADDR3 = P1^3; ***it ENLED = P1^4; unsigned char code led[] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90}; unsigned char ledbuff[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; unsigned long sec = 0, sec1; unsigned int cnt = 0; unsigned char flag = 0, i = 5, aa[6], b; void main() { ENLED = 0; ADDR3 = 1; TMOD = 0x01; TH0 = 0xfc; TL0 = 0x66; EA = 1; ET0 = 1; TR0 = 1; while (1) { if (flag == 1) { flag = 0; sec++; } aa[0] = sec % 10; aa[1] = sec / 10 % 10; aa[2] = sec / 100 % 10; aa[3] = sec / 1000 % 10; aa[4] = sec / 10000 % 10; aa[5] = sec / 100000 % 10; for (b=5; b>0; b--) { if (aa == 0) { ledbuff = 0xff; } else { break; } } for ( ; b>=0; b--) { ledbuff = led[aa]; } } } void interrupttimer() interrupt 1 { TH0 = 0xfc; TL0 = 0x66; cnt++; if (cnt == 1000) { cnt = 0; flag = 1; } P0 = 0xff; switch (i) { case 5: ADDR2 = 1; ADDR1 = 0; ADDR0 = 1; P0 = ledbuff[5]; i--; break; case 4: ADDR2 = 1; ADDR1 = 0; ADDR0 = 0; P0 = ledbuff[4]; i--; break; case 3: ADDR2 = 0; ADDR1 = 1; ADDR0 = 1; P0 = ledbuff[3]; i--; break; case 2: ADDR2 = 0; ADDR1 = 1; ADDR0 = 0; P0 = ledbuff[2]; i--; break; case 1: ADDR2 = 0; ADDR1 = 0; ADDR0 = 1; P0 = ledbuff[1]; i--; break; case 0: ADDR2 = 0; ADDR1 = 0; ADDR0 = 0; P0 = ledbuff[0]; i=5; break; default : break; } } 这个程序是数码管高位位零时不显示,怎么不对啊,求解 |
|
相关推荐
3个回答
|
|
|
|
|
|
for ( ; b>=0; b--)
{ ledbuff = led[aa]; } 这句有问题,我把b定义为unsigned char型,b就一直大于0零,不能小于零,所以这就成了一个死循环。 昨晚找了好久才找出来! |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
809 浏览 0 评论
1161 浏览 1 评论
2535 浏览 5 评论
2871 浏览 9 评论
移植了freeRTOS到STMf103之后显示没有定义的原因?
2719 浏览 6 评论
keil5中manage run-time environment怎么是灰色,不可以操作吗?
1100浏览 3评论
198浏览 2评论
464浏览 2评论
378浏览 2评论
M0518 PWM的电压输出只有2V左右,没有3.3V是怎么回事?
459浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 04:31 , Processed in 1.142294 second(s), Total 83, Slave 64 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号