完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在使用一个DSPIC33 FJ128GP706A。我正在尝试检测一个连接到引脚17(RB6/AN6)的开关。我已将其连接在以下配置中:+3.3V->100欧姆->Switch->使用10K下拉电阻器连接到引脚和地面。以下是用于读取压力然后释放开关的代码:.(!{B} { }同时(PurbButs.RB6){},当我处于调试模式时,这是完美的。然而,当我对PIC进行编程时,处理器从来没有检测到按下按钮,随后的代码执行也没有发生。
以上来自于百度翻译 以下为原文 I am working with a dsPIC33FJ128GP706A. I am trying to detect a switch that is connected to Pin 17 (RB6/AN6). I have it connected in the following configuration: +3.3V -> 100 ohm -> Switch -> connect to pin and ground using a 10K pull down resistor. Here is the code used to read the press and then release of the switch: while( !PORTBbits.RB6) { } while(PORTBbits.RB6) { } This works perfectly when I am in debug mode. However, when I program the PIC, the processor never detects the button press and subsequent code execution does not occur. I have set configured the Digital I/O correctly and also verified the ADPCFG bit associated with it. Attached Image(s) |
|
相关推荐
7个回答
|
|
你确定吗?如果你真的想得到帮助,最好把你的实际代码展示给一双新的眼睛看。
以上来自于百度翻译 以下为原文 Are you sure? If you really want help with this, it would be better to show your actual code for a fresh pair of eyes to see. |
|
|
|
虽然它看起来工作得很完美,但我想它可能正在做“奇怪”的事情,但是到目前为止你还是看不到。你需要去掉开关——仅仅读端口是不够的。苏珊
以上来自于百度翻译 以下为原文 While it mighty look as though it is working perfectly, I think it might be doing 'strange' things but so far you cannot see them. You need to debounce the switch - simply reading the port is not enough. Susan |
|
|
|
ALL:开关被一个10英寸KS@ SRIDHAR的盖帽弹出:你检查电源了吗?DSPIC是否运行?
以上来自于百度翻译 以下为原文 @all: the switch is debounced by a cap ║ the 10 k. @Sridhar: did you check the supply? Does the dsPIC run at all? |
|
|
|
由于GP706(A)有两个片上ADCs,所以必须根据您的需要配置AD1PCFG和AD2PCFG。
以上来自于百度翻译 以下为原文 Since the GP706(A) have two on-chip ADCs, you must configure both AD1PCFG and AD2PCFG according to you needs. |
|
|
|
@澳大利亚苏珊。我有一个开关以类似的方式连接到引脚RD8和RF6(没有跨过电阻分压的电容器)。它们不作为ADC端口。我可以在相同的循环读取程序模式,没有问题。这只是一个引脚RB6,我很难用一个while循环来切换开关。去抖动也不起作用。我已经查看了调试模式下的两个寄存器值。AD2PCFGL为0xFFFF。广告!PCFGL为0xFF40(在AN6点有1)。Turbibs.RB6=1也被定义在代码中。是的,PIC是功能性的。它被困在这个特殊的while循环中。程序的其他功能也很好。@ QHB。我已经在调试模式中通过了代码。我能读懂开关。我甚至设置了一个LED开关在while循环检查,它的工作原理。当我把PIC放在程序模式中时,它就不再读取开关了。
以上来自于百度翻译 以下为原文 @Aussie Susan . I have another switch connected in a similar fashion (without the capacitor across the resistor divide) connected to pins RD8 and RF6). They do not serve as ADC ports. I can read them in the same while loop in program mode without a problem. It is just that one pin RB6 that I am having trouble reading the switch with a while/if loop. @all. Debouncing does not work either. @MBedder. I have looked at both the register values in debug mode. AD2PCFGL is 0xFFFF. AD!PCFGL is 0xFF40 (Has a 1 in the AN6 spot). TRISBbits.RB6 = 1 is defined in code too. @du00000001. Yes the PIC is functional. It gets stuck in this particular while loop. Other functions of the program are working fine. @qhb. I have stepped through the code in debug mode. And I am able to read the switch. I even set an LED toggle inside the while loop to check and it works fine. The moment I put the PIC in program mode, it does not read the switch anymore. |
|
|
|
@摩贝德。我确实回去做了一些测试。在这个过程中,我发现ADXPCFGL位都需要显式设置为0xFFFF,无论它们是否在ADC开放函数中得到修改。谢谢你的建议。
以上来自于百度翻译 以下为原文 @MBedder. I did go back and do some more testing. In the process, I did find that both the ADxPCFGL bits need to explicitly set to 0xFFFF, whether or not they get modified in the ADC open functions. Thanks for your suggestion. |
|
|
|
通常的罪魁祸首是在调试模式下,AD1PCFG和AD2PCFG都通过调试执行代码静默地设置为数字模式,调试执行代码在编程期间被预加载到MCU。MCHP文档中很少(如果有的话)提到这个特性,所以它仍然像它迷惑您一样迷惑许多用户。
以上来自于百度翻译 以下为原文 The usual culprit is that in Debug mode both AD1PCFG and AD2PCFG are silently set to digital mode by the Debug Executive code which is preloaded to the MCU during the programming. There are few (if any) references to this feature in the MCHP documentation, so it still confuses many users the same way it confused you. |
|
|
|
只有小组成员才能发言,加入小组>>
5184 浏览 9 评论
2005 浏览 8 评论
1932 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3179 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2230 浏览 5 评论
742浏览 1评论
629浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
512浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
640浏览 0评论
538浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-28 22:44 , Processed in 1.371860 second(s), Total 89, Slave 72 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号