完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我正在看汽车联网开发板(ADM900716)和PIC18F66 K80 100引脚PIM的演示固件。我已经附加了示例代码的zip文件。它目前只是闪烁一些LED。我想使用开关发光和LED,但到目前为止,我还没有成功地能够读取开关的输入。代码的相关部分如下所示。不管我做什么,结果仍然是0。我做错什么了?
以上来自于百度翻译 以下为原文 Hello, I am looking at the Automotive networking development board (ADM00716) and the demo firmware for the PIC18F66K80 100 pin PIM. I have attached the zip file of the example code. It currently just flashes some of the LEDs. I want to use the switches to light and LED but so far I have not been successfully able to read inputs from the switches. The relevant section of the code is shown below. No matter what I do, result still comes out as 0. What am I doing wrong? void main(void) { int result = 0; InitializeDevice(); // Initialize modules BlinkLEDs(3); Delay(One_ms); while(1) { result = PORTAbits.RA0; if(result){ LATD = 0x81; } } } Attachment(s) 66K80 PIM Code.zip (55.81 KB) - downloaded 11 times |
|
相关推荐
6个回答
|
|
您正在检查RA0,但是您的源代码表示有一个连接到RA0的POT,并将其配置为模拟输入。您确定您的按钮是否连接到该PIN?
以上来自于百度翻译 以下为原文 You're checking RA0, but your source code says there is a pot connected to RA0, and configures it as an analog input. Are you sure your button is connected to that pin? |
|
|
|
此外,通常情况下,也包括相反的情况:
以上来自于百度翻译 以下为原文 Also, usually it's better the include also opposite case: if(result) LATD = 0x81; else LATD = 0; |
|
|
|
QHB:对不起,是的,这是我的一个打字,虽然我不是100%确定按钮是正确地连接到针的问题。我怎么检查呢?DarioG:你说得对,我已经把相反的情况包括进去了。代码看起来是这样的,这就是代码现在看起来的样子,但是问题仍然存在。
以上来自于百度翻译 以下为原文 qhb: sorry, yeah that was a typo on my part, although I am not 100% sure the button is properly connected to the pin in question. How would I check that? DarioG: You're right, I have included the opposite case now. The code looks like this now This is how the code looks now but the issue still remains. while(1) { result = PORTEbits.RE0; if(result){ LATD = 0x42; }else{ LATD = 0x0; } } |
|
|
|
HiVMC,这是因为Re0没有连接到任何汽车联网板的开关。PIC18F66 K80 100引脚插件模块用户指南:HTTP:/WW1.MICCHIP.COM/DIXBOSS/En/DeVICECD/OC0401857 A.PDFAutoMutual网络开发板用户指南:HTTP:/WW1.MICCHIP.COM/DUNDIPS/ENP/DeviceDoc /4000 1862A。PDFLY是对汽车联网板电位器、开关和LED的设备PIN路由的摘要:[图像]文件:///A16026/台式机/66 K80Z-ToAutoBoad路由。PNG[/MIX] [图像]文件://Cu/A16026/Tabe/6K80TooBooBoad路由。PNG/[图像]谢谢。Tam
以上来自于百度翻译 以下为原文 Hi VMC, This is because RE0 is not connected to any of the Automotive Networking Board's switches. PIC18F66K80 100-Pin Plug-In Module User’s Guide: http://ww1.microchip.com/downloads/en/DeviceDoc/40001857A.pdf Automotive Networking Development Board User’s Guide: http://ww1.microchip.com/downloads/en/DeviceDoc/40001862A.pdf Here's a summary of the device's pin routing to the Automotive Networking Board's potentiometer, switches and LEDs: [image]file:///C:/Users/A16026/Desktop/66K80_to_AutoBoard_Routing.png[/image][image]file:///C:/Users/A16026/Desktop/66K80_to_AutoBoard_Routing.png[/image] Thanks, Tam |
|
|
|
请参阅附件。对不起,我不能编辑。我得到“拒绝访问”。
以上来自于百度翻译 以下为原文 Please see attached. Sorry, I can't edit. I'm getting "Access Denied". Attached Image(s) |
|
|
|
哦,是的,我没有正确地连接按钮,我试过你的方法,效果不错。非常感谢你的帮助!
以上来自于百度翻译 以下为原文 @Tam Oh yeah, I hadn't connected the button properly, I tried your method and it worked. Thank you so much for your help! |
|
|
|
只有小组成员才能发言,加入小组>>
5253 浏览 9 评论
2038 浏览 8 评论
1958 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3219 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2267 浏览 5 评论
792浏览 1评论
686浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
617浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
686浏览 0评论
586浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-30 09:23 , Processed in 1.454558 second(s), Total 85, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号