完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
新手小弟
PIC里为什么跳不过延时函数,到了延时函数这里就停下了。 以下是程序: #include __CONFIG(PROTECT & DEBUGDIS & WRTEN & DPROT & LVPEN & BORDIS & PWRTEN & WDTDIS & XT); void delay() { unsigned int a=1000,b=1000; for(a;a>0;--) for(b;b>0;--); } void main() { TRISA=0x00; TRISC=0x00; TRISE=0x00; TRISB=0x00; TRISD=0x00; PORTA=0xff; PORTB=0x00; PORTC=0xff; PORTD=0x00; PORTE=0xff; unsigned char t=10; while(1) { RB0=0x00; delay(t); RB0=0x01; delay(t); } } |
|
相关推荐
2 个讨论
|
|
|
改程序为:
void delay(unsigned int x) { //unsigned int a=1000,b=1000; unsigned int a,b; a=x; b=x; for(a;a>0;--) for(b;b>0;--); } void main() { TRISA=0x00; TRISC=0x00; TRISE=0x00; TRISB=0x00; TRISD=0x00; PORTA=0xff; PORTB=0x00; PORTC=0xff; PORTD=0x00; PORTE=0xff; unsigned char t=10; while(1) { RB0=0x00; delay(1000); RB0=0x01; delay(1000); } } |
|
|
|
|
|
|
|
|
#include __CONFIG(PROTECT & DEBUGDIS & WRTEN & DPROT & LVPEN & BORDIS & PWRTEN & WDTDIS & XT); void delay(unsigned int t) { unsigned int a,b=1000; a=t; for(a;a>0;--) for(b;b>0;--); } void main() { TRISA=0x00; TRISC=0x00; TRISE=0x00; TRISB=0x00; TRISD=0x00; PORTA=0xff; PORTB=0x00; PORTC=0xff; PORTD=0x00; PORTE=0xff; unsigned int TIME=10; while(1) { RB0=0x00; delay(TIME); RB0=0x01; delay(TIME); } } |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 06:40 , Processed in 0.625699 second(s), Total 46, Slave 35 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
10040
