完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
你好,我用下面的代码,16f690在pickit 2演示板上,LED保持打开,按下或不按下,有什么想法吗?
以上来自于百度翻译 以下为原文 Hello, I am using the following code with 16f690 on pickit 2 demo board, #define _XTAL_FREQ 4000000 #include // BEGIN CONFIG #pragma config MCLRE = OFF #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled) //#pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming) #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off) //#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control) #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) //END CONFIG int main() { ANSEL = 0; ANSELH = 0; TRISC0 = 0; TRISA3 = 1; RC0 = 0; //LED Off while(1) { if(RA3==0) { RC0 = 1; } else { RC0 = 0; } } return 0; } The LED just remains on, switch pressed or not, any ideas? |
|
相关推荐
3个回答
|
|
如果不使用LVP模式,请保持LVP=关闭。您确定PIC正在运行吗?你的外部振荡器在运行吗?尝试LED闪烁循环以确保它正在运行。只需打开LED输出,等待,关掉,等待,循环,也不是MPLABX问题!最好是在XC8论坛……
以上来自于百度翻译 以下为原文 Keep LVP = OFF if you are NOT using LVP mode. Are you sure the pic is running? Is your external oscillator running? Try a LED blink loop to be sure it is running. Just turn the LED output ON, wait, turn it OFF, wait, loop. Also NOT an MPLABX question! Better to be in the XC8 forum...... |
|
|
|
正如达里奥所说,你需要确定你的PIC实际上是先运行的,所以你应该先点亮一个LED而不用担心开关。否则你要同时测试两个未知数。也就是说,是输入或输出的问题。无论如何,试试这个版本,它使用内部时钟,而不是外部时钟,它消除了一个更多的未知数……
以上来自于百度翻译 以下为原文 As Dario said, you need to establish that your PIC is actually running first, so you should have just started by flashing an LED without worrying about the switch. Otherwise you are trying to test two unknowns at the same time. i.e. is the problem in the input, or the output. Anyway, try this version, which uses the internal clock rather than an external one, which eliminates one more unknown... #include #define _XTAL_FREQ 4000000 // BEGIN CONFIG #pragma config MCLRE = OFF #pragma config FOSC = INTOSCIO // Oscillator Selection bits (internal oscillator) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled) #pragma config LVP = OFF // Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming) #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off) #pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control) #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) //END CONFIG void main(void) { ANSEL = 0; //all inputs are digital ANSELH = 0; TRISC0 = 0; //RC0 is output TRISA3 = 1; //RA3 is digital input RC0 = 0; //LED Off while(1) { if(RA3 == 0) { RC0 = 1; } else { RC0 = 0; } } } |
|
|
|
不承认?在16F690手册中,它也说要使用ItoSoCo?我试了试,它接受了,虽然它仍然不工作。我的配置是否会出错,因为它不能识别国际信息中心?编辑:明白了,我需要释放3状态的复位(别忘了我正在使用RA3)。但是,这仍然不能解释不能像手册中所说的那样使用INTOSCIO?这是与手册的手册没有提到。这是我的配置位选择器中的一个选项,所以我选择了:
以上来自于百度翻译 以下为原文 INTOSCIO not recognised?? In the 16f690 manual it says to use INTOSCIO too? I tried INTRCIO and it accepts it, although its still not working. Could my configuration be wrong somewhere for it not to recognise INTOSCIO? EDIT: Got it, I needed to release the reset for the 3 state (dont forget I am using RA3). However, this still doesnt explain not being able to use INTOSCIO like it says in the manual? It is working with INTRCIO which the manual does not mention.. This was an option in my configuration bits selector so I selected it :s #include #define _XTAL_FREQ 4000000 // BEGIN CONFIG #pragma config MCLRE = OFF #pragma config FOSC = INTRCIO // Oscillator Selection bits (internal oscillator) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT enabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) #pragma config BOREN = ON // Brown-out Reset Enable bit (BOR enabled) //#pragma config LVP = OFF// Low-Voltage (Single-Supply) In-Circuit Serial Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming) #pragma config CPD = OFF // Data EEPROM Memory Code Protection bit (Data EEPROM code protection off) //#pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off; all program memory may be written to by EECON control) #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) //END CONFIG void main(void) { ANSEL = 0; //all inputs are digital ANSELH = 0; TRISC0 = 0; //RC0 is output TRISA3 = 1; //RA3 is digital input RC0 = 0; //LED Off while(1) { if(RA3 == 0) { RC0 = 1; } else { RC0 = 0; } } } |
|
|
|
只有小组成员才能发言,加入小组>>
5248 浏览 9 评论
2036 浏览 8 评论
1956 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3217 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2264 浏览 5 评论
782浏览 1评论
676浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
602浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
684浏览 0评论
581浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-26 13:32 , Processed in 1.273670 second(s), Total 82, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号