完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我有一个愚蠢的问题,我找不到原因。我试图得到一个瞬时按钮开关触发IOC中断的PIN RB0的8位PIC16F15355。我使用MCC配置PIN作为输入,IOC正边,使用内部WPU电阻器。引脚设置为模拟,虽然我有同样的问题与模拟框未经检查。我试着检测到一个负的边缘,但仍然没有乐趣。问题是,当我瞄准引脚,它已经读了大约1.5 V,中断不火,即使开关跳转到3.3的电压。为什么管脚不在0伏?端口B中的其他引脚位于0(如波尔塔和PORTC中的所有引脚一样)。我已经测试了开关,它工作正常。我敢肯定,RB0引脚是把电压,我不认为它应该是。一旦软件开始运行,电压就会上升,即使在调试阶段结束后,电压也会上升。它也保持在1.5 V,即使在我驱动MCLR高。它这样做使用MCC生成的代码。我唯一的代码添加是对默认中断处理程序内部的计数变量进行加扰,它从不运行。在PixMealth.C中,TrISA、TrISB和TrISC都设置为0xFF,这是输入。我使用MPLAB X V4.10(在V4.20启动时有死锁),XC8编译器V1.44,但我怀疑两者是否是一个因素。MCC V 3.55.1。在电路运行时保持连接的拾取3,也应该是好的。一定有我正在做的事情,或者没有做过我应该做的事情,这就是造成这个问题的原因。这是非常可重复的,发生在几个PIC芯片,所以它不是一个有缺陷的处理器。如有任何建议,将不胜感激。提前感谢。
以上来自于百度翻译 以下为原文 I'm having a stupid problem I can't find the cause of. I'm trying to get a momentary pushbutton switch to trigger an IOC interrupt on pin RB0 of an 8 bit PIC16F15355. I'm using MCC to configure the pin as an input, IOC positive edge, using the internal WPU resistor. The pin is set to analog, though I have the same problem with the analog box unchecked. I've tried detecting a negative edge, and still no joy. The problem is that when I scope the pin, it's already reading about 1.5 V, and the interrupt doesn't fire, even though the switch jumps the voltage to 3.3. Why isn't the pin at 0 V? The other pins in Port B are at 0 (as are all the pins in PORTA and PORTC). I've tested the switch, and it's working correctly. I'm quite sure the RB0 pin is putting out the voltage, and I don't think it should be. The voltage rises as soon as the software starts to run, and stays up even after I finish the debug session. It also stays at 1.5 V even after I drive MCLR high. It does this using the MCC generated code. My only code addition was to incriment a Count variable inside the default interrupt handler, which never runs. In pin_manager.c, TRISA, TRISB, and TRIS C are all set to 0xFF, which are inputs. I'm using MPLab X V4.10 (got deadlocks on starting V4.20), and the XC8 compiler V1.44, though I doubt that either is a factor. MCC V 3.55.1. PICkit 3 that stays connected while the circuit is running, which should also be fine. There must be something I'm doing, or haven't done something I should, that's causing this issue. It's very repeatable, happening with several PIC chips, so it's not a defective processor. Any suggestions would be most appreciated. Thanks in advance. |
|
相关推荐
4个回答
|
|
不要将引脚设置为模拟。这使得它总是读为零。把它设置成数字。因为你启动了一个微弱的上拉。你的开关应该连接到地上,在这个模式下切换,并检测下降沿。
以上来自于百度翻译 以下为原文 Do NOT set the pin to analog. That makes it always read as zero. Set it to digital. Because you enabled a weak pull up. Your switch should be connected to ground to switch it in this mode, and detect the falling edge. |
|
|
|
似乎很多人把开关从一个输入到VDD,这需要一个下拉。最好使用牵引,并切换到GND。这也可以更好地用于噪声目的-开关可以连接到接地平面。此外,我喜欢负载如LED(通过电阻器)连接到Vdd,并使用(往往更强)低输出来驱动它们。可能有些人很难掌握否定或反相逻辑,其中0是ON,1是OFF。
以上来自于百度翻译 以下为原文 It seems a lot of people put switches from an input to Vdd, which necessitates a pull-down. It is better to use pull-ups, and switches to GND. This may be better for noise purposes as well - the switches can be connected to the ground plane. Also, I like to have loads such as LEDs connected (through resistors) to Vdd, and use the (often stronger) low output to drive them. It may be that some folks have difficulty grasping negative or inverting logic, where 0 is ON and 1 is OFF. |
|
|
|
感谢所有回应的人。我已经修改了电路,它现在起作用了。我是一个软件人,刚刚开始探索硬件。我对如何使用PIC的内部WPU的理解是错误的——似乎它不仅将电阻器连接到引脚,而且还将电阻器连接到电源。我已经从数据表重读了WPU,并没有明确地提到这个细节,但是根据观察到的行为是有意义的。我知道我有很多东西要学,这个练习很有启发性。再次感谢你的建议。
以上来自于百度翻译 以下为原文 Thanks to all who responded. I've revised the circuit and it works now. I'm a software guy just getting to explore the hardware. My understanding of how to use the PIC's internal WPU was wrong - it seems that not only does it connect a resistor to the pin, it also connects that resistor to power. I've reread about WPU from the datasheet, and didn't see an explicit mention of this detail, but it makes sense according to the observed behavior. I know I've a lot to learn, and this exercise has been illuminating. Thanks again for your advice. Bob |
|
|
|
“弱拉起”这个名字应该是个暗示。:)
以上来自于百度翻译 以下为原文 The name "Weak Pull Up" should have been a hint. :) |
|
|
|
只有小组成员才能发言,加入小组>>
5166 浏览 9 评论
2000 浏览 8 评论
1928 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3174 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2226 浏览 5 评论
733浏览 1评论
615浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
505浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
631浏览 0评论
528浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 06:10 , Processed in 1.272258 second(s), Total 84, Slave 68 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号