完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
|
题目:使用单片机的定时器1让个LED循环右移,间隔500ms,同时使用定时器0中断方式让数码管前两位间隔1000ms从0显示到60程序:
#include #include #define uchar unsigned char #define uint unsigned int void T1init(); void T0init(); void display(short num); uchar code leddata[]={ 0xC0, //"0" 0xF9, //"1" 0xA4, //"2" 0xB0, //"3" 0x99, //"4" 0x92, //"5" 0x82, //"6" 0xF8, //"7" 0x80, //"8" 0x90 //"9" }; uchar temp; short count, count2, count_time; int main(void) { T1init(); T0init(); temp = 0xfe; P1 = temp; while(1) { if(TF1 == 1) { TF1 = 0; TH1 = 0x4b; TL1 = 0xfd; count++; } if(count == 10) { count = 0; temp = _cror_(temp , 1); P1 = temp; } display(count_time); } return 0; } void T1init() { TMOD = 0x11; TH1 = 0x4b; TL1 = 0xfd; TR1 = 1; } void T0init() { TMOD = 0x11; TH0 = 0x4b; TL0 = 0xfd; TR0 = 1; ET0= 1; EA = 1; } void timer0(void)interrput 1 { TH0 = 0x4b; TL0 = 0xfd; count2++; if(count2 == 20) { count2 = 0; count_time++; } if(count_time == 60) { count_time = 0; } } void display(short num) { short shi, ge; shi = num / 10; ge = num % 10; P2 = 0xfe; P0 = leddata[shi]; P0 = 0xff; P2 = 0xfd; P0 = leddata[ge]; P0 = 0xff; } 编译程序时出现问题: INTERRUPT2.C(66): error C132: 'interrput': not in formal parameter list INTERRUPT2.C(66): error C141: syntax error near '1' INTERRUPT2.C(68): error C244: 'TH0': can't initialize, bad type or class INTERRUPT2.C(68): error C132: 'TH0': not in formal parameter list INTERRUPT2.C(69): error C244: 'TL0': can't initialize, bad type or class INTERRUPT2.C(69): error C132: 'TL0': not in formal parameter list INTERRUPT2.C(70): error C132: 'count2': not in formal parameter list INTERRUPT2.C(70): error C141: syntax error near '++' INTERRUPT2.C(73): error C244: 'count2': can't initialize, bad type or class INTERRUPT2.C(73): error C132: 'count2': not in formal parameter list INTERRUPT2.C(74): error C132: 'count_time': not in formal parameter list INTERRUPT2.C(74): error C141: syntax error near '++' INTERRUPT2.C(78): error C244: 'count_time': can't initialize, bad type or class INTERRUPT2.C(78): error C132: 'count_time': not in formal parameter list INTERRUPT2.C(79): error C141: syntax error near '}' 看了一下,不知道怎么解决,需要大家帮帮看看哪里出了问题。 |
|
相关推荐
3个回答
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
谢谢,完美的解决了我的问题 |
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
265 浏览 0 评论
【原创】【RA4M2-SENSOR开发板评测】低功耗+USB综合测试
789 浏览 0 评论
1306 浏览 2 评论
787 浏览 0 评论
【RA4M2-SENSOR开发板评测】Analogue+Timers综合测试
1587 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
16900 浏览 31 评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 01:21 , Processed in 0.728796 second(s), Total 78, Slave 60 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
587