完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
`我的开发板的数码管原理图是这样的 我的显示程序是这样的,但每次下载完程序或者上电后都不能正常显示0,要复位后才能正常显示,而下载开发板的例程则不会出现异常 #include #include #define uchar unsigned char #define uint unsigned int #define uint32 unsigned long const uchar table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71}; volatile uint32 num; void delay(uchar x) { uchar y; uint z; for(y=0;y } void display(void) { uchar ge,shi,bai,qian; ge=num%10; shi=num%100/10; bai=num%1000/100; qian=num/1000; SPSR=0; SPDR=table[ge]; delay(2); PORTK|=BIT(3); delay(1); PORTK&=~BIT(3); PORTL=0x01; delay(3); PORTL=0; SPSR=0; SPDR=table[shi]; delay(2); PORTK|=BIT(3); delay(1); PORTK&=~BIT(3); PORTL=0x02; delay(3); PORTL=0; SPSR=0; SPDR=table[bai]; delay(2); PORTK|=BIT(3); delay(1); PORTK&=~BIT(3); PORTL=0x04; delay(3); PORTL=0; SPSR=0; SPDR=table[qian]; delay(2); PORTK|=BIT(3); delay(1); PORTK&=~BIT(3); PORTL=0x08; delay(3); PORTL=0; } void init(void) { SPCR=0x53; DDRB|=0x0f; PORTB=0x0f; DDRK|=BIT(3); DDRL|=0x0f; num=0; } void main(void) { init(); while(1) { display(); } } `
|
|
相关推荐
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
265 浏览 0 评论
【原创】【RA4M2-SENSOR开发板评测】低功耗+USB综合测试
789 浏览 0 评论
1306 浏览 2 评论
787 浏览 0 评论
【RA4M2-SENSOR开发板评测】Analogue+Timers综合测试
1587 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
16902 浏览 31 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 12:39 , Processed in 0.521100 second(s), Total 72, Slave 52 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2651