完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
大家好,我想用我的PIC16F88闪烁一个LED。但当我的手靠近PIC或电池时,它自己复位或LED保持。真的很奇怪。你能帮帮我吗?谢谢,这是密码。
以上来自于百度翻译 以下为原文 Hi everyone , I'm trying to blink a led with my PIC16F88. But when I got my hand close to PIC or battery it's resetting itself or led stays on. It's really weird. Can you help me please ? Thank you. Here is the code. #include #include #include // CONFIG1 #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator) #pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled) #pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled) // RA5/MCLR/VPP Pin Function Select bit (RA5/MCLR/VPP pin function is MCLR) #pragma config BOREN = OFF // Brown-out Reset Enable bit (BOR disabled) #pragma config LVP = OFF // Low-Voltage Programming Enable bit (RB3 is digital I/O, HV on MCLR must be used for programming) #pragma config CPD = OFF // Data EE Memory Code Protection bit (Code protection off) #pragma config WRT = OFF // Flash Program Memory Write Enable bits (Write protection off) // CCP1 Pin Selection bit (CCP1 function on RB0) #pragma config CP = OFF // Flash Program Memory Code Protection bit (Code protection off) #define _XTAL_FREQ 8000000 void main(){ OSCCON = 0x7C; TRISB = 0x00; while(1){ PORTBbits.RB0 = 1; __delay_ms(500); PORTBbits.RB0 = 0; __delay_ms(500); } } |
|
相关推荐
19个回答
|
|
|
什么振荡器?你有一个8MHz的晶体连接到OSC引脚?(编辑:为什么你要写信给OSCCon寄存器,当你的配置位说你在使用一个外部振荡器)你有一个上拉电阻连接到MCLR吗?你把所有不用的门栓都当作输入,它们是高还是低?您的程序员(PK3等)在测试时仍然连接吗?
以上来自于百度翻译 以下为原文 What oscillator? Do you have an 8MHz crystal connected to the OSC pins? (Edit: and why are you writing to the OSCCON register, when your config bits say you are using an external oscillator) Do you have a pullup resistor connected to MCLR? You have left all the unused PORTA pins as inputs. Are they tied high or low? Is your programmer (PK3 etc.) still connected when you test? |
|
|
|
|
|
它就像魔术一样……好吧,真的,它的杂散电容。给我们看一张你的PIC面包板的照片
以上来自于百度翻译 以下为原文 its like magic :).... well ok really its stray capacitance. show us a picture of your pic bread board |
|
|
|
|
|
我尝试使用内部振荡器。我没有任何上拉电阻器,它只是一个在电路板上的PIC和一个带220OHM电阻的LED。我增加了TrISA=0x00;在我的代码中,它现在解决了问题。有什么办法来解决这个问题吗?如果你做了一个敏感的重要电路,将来你不想有这个问题,你会怎么做?我的程序员没有连接到电路板。我在PK3上编程,然后把PIC放在电路板上。我的电池是3.7V,这对PIC来说是不好的。对不起,我的愚蠢问题,我想学习:)谢谢!
以上来自于百度翻译 以下为原文 I'm trying to use internal oscillator. I don't have any pull up resistors, its just a pic on breadboard and one led with 220ohm resistor. I've added TRISA = 0x00; in my code and it fixed the problem now. Is there any way to fix this problem ? What would you do if you made an sensitive important circuit and you do not want to have this problem in future? My programmer is not connected to breadboard. Im programming it on PK3 and then putting the pic on breadboard. Also , my battery is 3.7V , is it bad or OK for that PIC. Sorry for my stupid questions I'm trying to learn :) And thank you! |
|
|
|
|
|
然后,将Y.PrimaMatlab配置为FASC=hs//振荡器选择位(HS振荡器),将其转换为γ-PrimaAcFig FoCc=内/ /振荡器选择位(内部振荡器),然后,如果使用配置位编辑器窗口,则还需要禁用具有μ* PrimaMac配置文件MCLRE=OFIT的MCLR PIN将是最安全的。在MPLABX中设置所有选项,然后将生成的代码粘贴到源代码中。XC.H应该包含在“{ TraceMaqFig”行之后),并且不需要包括STDIO。
以上来自于百度翻译 以下为原文 Then change #pragma config FOSC = HS // Oscillator Selection bits (HS oscillator) to #pragma config FOSC = INTRC // Oscillator Selection bits (Internal oscillator) Then you also need to disable the MCLR pin with #pragma config MCLRE = OFF It would be safest if you used the configuration bit editor windows in MPLABX to set all the options, then paste the generated code into your source. xc.h should be included AFTER the "#pragma config" lines, and you do not need to include stdio.h or stdlib.h |
|
|
|
|
|
这是图片,只是一个简单的电路图//I.Gigur.COM/N1UPCCV.JPG
以上来自于百度翻译 以下为原文 Here is the picture, just a simple circuit https://i.imgur.com/N1upccV.jpg |
|
|
|
|
|
|
|
|
|
|
|
如果你把一个5针头放到你的键盘上,连接到命令的ToCLRVDDVSSPGDPGCCIN,那么你就可以将你的PK3直接插入到电路板中,而不必移除PIC。这也会让你在电路调试中进行。
以上来自于百度翻译 以下为原文 If you put a 5 pin header into your breadboard, connected to MCLR VDD VSS PGD PGC in that order, then you could plug your PK3 straight into the breadboard rather than having to remove the PIC. That would also let you do in circuit debugging. |
|
|
|
|
|
HTTPS5.//IGUUR.COM/MGI6ZUC.JPGI完成了它,MPLAB IPE成功地连接到“程序员到目标电源启用- VDD=5伏。目标设备PIC16F88发现。设备ID修订=8”,但是当我单击“从MPLAB IDE调试主项目”按钮时,它说“无效命令响应”。(发送0x3f,接收0x41)“白色LED也停止闪烁,现在就打开。
以上来自于百度翻译 以下为原文 https://i.imgur.com/MgI6ZuC.jpg I did it and the MPLAB IPE is successfully connected " Programmer to target power is enabled - VDD = 5.000000 volts. Target device PIC16F88 found. Device ID Revision = 8 " But when I click to "Debug Main Project" button from the MPLAB IDE , it says "Invalid command response (sent 0x3f, received 0x41)" Also white led is stopped blinking , it just on now. |
|
|
|
|
|
按钮仍然不工作,但是当我上传代码时,LED开始闪烁。真是太好了,你救了我的命。
以上来自于百度翻译 以下为原文 Button is still not working but when I upload the code led is started to blink. It's really better , you saved my life Smile: |
|
|
|
|
|
HTTP//WW1.MICCHIP.COM/DeLoSt/En/DeVICEDC/3087D.PDFI将在引脚5 VSS和PIN 14 VDD之间添加一个上限。
以上来自于百度翻译 以下为原文 http://ww1.microchip.com/downloads/en/DeviceDoc/30487D.pdf I would add a cap across pin 5 vss and pin 14 vdd. |
|
|
|
|
|
没有看到任何用按钮做任何事情……POTB设置为OutPoStRATA没有设置,所以设置为默认值…它们是什么?
以上来自于百度翻译 以下为原文 not seeing any code that does anything with a button.... portb set as outputs porta not set so is setup as defaults... ? what are they ? |
|
|
|
|
|
我想他指的是MPLAB中的一个按钮。POST第4页说“TrISA=0”。
以上来自于百度翻译 以下为原文 I think he's referring to a button in MPLAB. Post#4 says "TRISA=0;" was added. |
|
|
|
|
|
当我点击这个时,就会发生这种情况。但是我可以通过MPLAB IPE成功地将我的代码上传到PIC。现在,只是尝试调试这个项目。
以上来自于百度翻译 以下为原文 When I click to this , this happens. But I can successfully upload my codes to PIC via MPLAB IPE. Now , just trying to debug the project. |
|
|
|
|
|
|
|
|
|
|
|
是的,现在添加了(10FracARAD 16V),但仍然相同的错误。
以上来自于百度翻译 以下为原文 Yes added it now (10microFarad 16v) but still same error. |
|
|
|
|
|
太大了。这将是一个电解电容器,具有高ESR。你需要一个非常低的ESR电容器,像100NF陶瓷帽,与引线尽可能短地直接连接到PIC的电源引脚。
以上来自于百度翻译 以下为原文 Too big. That will be an electrolytic capacitor, with a high ESR. You need a very low ESR capacitor, like a 100nF ceramic cap, connected with the leads as short as possible directly to the PIC's power pins. |
|
|
|
|
|
好的,我会尽快找到一个。我希望这能解决这个问题。还有一个问题:“如果我把我的代码写进:int a=10;Print F(a);我能从我的计算机上通过PK3读取它吗?我知道Python,我可以用它读取USB端口。或者在调试代码时,它出现在MPLABUIDE的终端上吗?谢谢你的时间!
以上来自于百度翻译 以下为原文 OK , I will find one as soon as possible. I hope this will fix the problem. And one more question :) what if I write in to my codes : int a = 10; printf(a); Can I read it via PK3 from my computer ? I know python, I can read USB ports with it. Or while debugging the code , does it appear on MPLAB_IDE 's terminal ? Thank you for your time! |
|
|
|
|
|
Primff()不通过PICTIT3向PC发送数据。它可以发送数据到PICS串口,甚至LCD显示器。
以上来自于百度翻译 以下为原文 Printf() does not send data to the PC through the PICKit3. It can send data to the PICs serial port, or even an LCD display. And I do not think that is valid C. |
|
|
|
|
|
如果你在C中写代码= pPrimff(),那么它就不会编译,它需要一个字符串格式和参数,并将其打印到“标准输出流”STDUT。PICS没有严格意义上的“STDUT”,因为没有OS,只是一个裸露的金属芯片。如果我没有搞错,默认情况下PICTF在PUTF上只会放在UART1上。无论如何,使用上面的代码的PrimTf的正确方法将是类似的:%D告诉Prttf,你想把整数参数A解析为十进制数。PrtTf然后将其转换为ASCII表示并将其放在STDUT(或UART1上,在PIC上)。您可以使用SaMPTF来做同样的事情,但是将结果放在字符数组(字符串)中,然后您可以做任何您想做的事情:我会链接一个引用,说明如何正确使用Prtff,但是芙儿优。M不想让我张贴一个链接,所以…
以上来自于百度翻译 以下为原文 I'm pretty sure that won't compile if you write that in your code =P printf() in C takes a string format and parameters and prints it to the "standard output stream" stdout. PICs don't have "stdout" strictly speaking, since there is no OS, just a bare metal chip. If I'm not mistaken, printf on a PIC by default will just put out on UART1. Anyway, the proper way to use printf for the above code would be something like: int a = 10; printf("%d",a); the %d tells printf that your want to parse the integer parameter a as a decimal number. printf will then convert it to ascii representation and put it out on stdout (or UART1, on a PIC). You can use sprintf to do the same thing but place the result in a character array (string) that you could then do whatever you want with: int a = 10; char buffer[5]; sprintf(buffer,"%d",a); I'd link a reference to how to use printf properly but the forum doesn't want to let me post a link so... |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475 浏览 0 评论
5795 浏览 9 评论
2334 浏览 8 评论
2224 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3530 浏览 3 评论
1125浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1098浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
873浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
475浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 18:11 , Processed in 1.599907 second(s), Total 110, Slave 93 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2752