完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我尝试读取端口B引脚连接到交换机。我不能读取,我的配置看起来不错。*定义LED端口。RC0定义按钮PutbBut.RB3Valb主(空隙){TrISC= 0x00;TrISB=0x08;iTe=0;RBIE=0;而(1){if(Button=0){LED=1;}否则{LED=0;}}返回;}
以上来自于百度翻译 以下为原文 Hi , I try to read port B pin which is connected to switch. I cannot read and my configuration look ok. #define LED PORTCbits.RC0 #define BUTTON PORTBbits.RB3 void main(void) { TRISC = 0x00; TRISB |= 0x08; INTE = 0; RBIE = 0; while(1) { if( BUTTON == 0 ) { LED = 1; }else { LED = 0; } } return; } |
|
相关推荐
12个回答
|
|
为什么你想从你的(1)循环返回?你的交换机是如何连接到你的PIC的?你用上拉电阻了吗?
以上来自于百度翻译 以下为原文 Why do you want to return from your while (1) loop? How is your switch connected to your PIC? did you use a pull-up resistor? |
|
|
|
请始终指定您正在使用的PIC。请更精确地描述你的问题,你期望什么,你得到什么。你检查代码是否在运行?检查RB3引脚上的模拟功能。返回是在while循环之外。
以上来自于百度翻译 以下为原文 Please always specify which PIC you are using. Please be more precise with the description of your problem,- what you expect, what you get. Did you e.g. check that your code is running at all ? Check for analog functions on RB3 pin. The return is outside the while loop. |
|
|
|
|
|
|
|
对不起,没有用iF167指定零件号IAM。它是简单的键盘读取。我用1K外拔,开关的另一端接地。因此,如果按键按下,RB3引脚拉低。但上述SW总是读取引脚状态为低。I探针电压PIN是,它正在改变当新闻= 0 /释放= 1。我检查了D端口的相同顺序,工作正常。可能需要一些额外的配置端口B?关于“返回”,只需保持自动生成的莫坎。甚至不使用。
以上来自于百度翻译 以下为原文 Sorry for not specify the part no. Iam using 16f887. It is simple key pad read. I pulled up externally with 1k. Other end of switch is connected to ground. So if key pressed, RB3 pin pull low. But this above SW always read pin status as LOW. I probe voltage on pin be and it is changing when press = 0 / release =1. I checked same sequence for port D and works fine. May be need some extra configuration for port b ?! Regarding "return" , just keep auto generated by mokan. Even remove no use. |
|
|
|
是的,main不应该在嵌入式设备的上下文中“返回”或退出。但是main也是一个C空隙函数,它是由启动代码调用的。main将有一个(汇编)返回,有或没有返回语句。实际上它是由启动编解码器& lt;main main & gt;断头序列调用的。在XC16中,我仍然不将空函数中的“返回”作为最后的语句,因为它是冗余的,甚至可能在复制/粘贴等过程中由于运气不佳而导致错误。
以上来自于百度翻译 以下为原文 Yes, main should never "return" or exit in the context of embedded devices. But main is also just a C void function, which is called by the startup code. main will have an (assembler) return with or without that return statement. Actually it's called by the startup code call <_main> break sequence in XC16. Still I would not use "return" in void functions as last statement, since it is redundant and could even result in bugs when misplaced by bad luck during copy/paste etc. |
|
|
|
好啊。接受可以删除。但我的问题是读取端口B3引脚。读取B端口/使用通用输入引脚需要配置吗?除了TrISB寄存器?我的问题是,不能像其他端口一样读取端口B。与端口B PIN更改中断连接吗?在CCS中,我从来没有面对这个问题。
以上来自于百度翻译 以下为原文 Ok. Accept can be removed. But my problem is about to read port B3 pin. To read B port / use general input pin need any configuration? Except TRISB register?! My problem is , cannot read port B like other port. Any link with port b pin change interrupt? In CCS i never face this problem., Just found in this XC8 |
|
|
|
那么,您的代码与哪个端口/PIN一起工作?[编辑:好,我看到它的工作端口D ] B3与模拟功能共享。重置其设置为模拟。请阅读您的手册DS41291F,第3.2章。3.3和ANSELX寄存器。它应该回答所有的问题,寄存器描述也说明复位后的设置。
以上来自于百度翻译 以下为原文 B3 is shared with analog functions. After reset its set to analog. Please read your manual DS41291F, chapter 3.2. / 3.3 and ANSELx registers. It should answer all your questions, the register description also states the setting after reset. |
|
|
|
对不起的。我的芯片是16F87.模拟端口在这个IF端口A中,现在问题是B端口。
以上来自于百度翻译 以下为原文 Sorry. My chip is 16F887. The analog port is in this if port A. Now problem is port B |
|
|
|
正如数据表清楚地指出的:RB3/AN9/PGM/C12In-
以上来自于百度翻译 以下为原文 As the data sheet clearly says: RB3/AN9/PGM/C12IN2- |
|
|
|
|
|
|
|
您好,正如JTEMPPLESHTTP//www. McCHIP.COM/FUMMS/FANDPOST/1024266所提到的,您需要将ADC和比较器控制寄存器初始化,以便PIN RB3可以用作I/OrrADARS。
以上来自于百度翻译 以下为原文 Hi, As mentioned by JTEMPLES http://www.microchip.com/forums/FindPost/1024266 you will need to intialize BOTH the ADC AND COMPARATOR control registers so that the pin RB3 can be used as an I/O Regards |
|
|
|
安塞尔-端口B模拟/数字功能控制寄存器-数据表的第49页。
以上来自于百度翻译 以下为原文 ANSELH - PORT B analog/digital function control register - page 49 of the datasheet. |
|
|
|
只有小组成员才能发言,加入小组>>
5139 浏览 9 评论
1987 浏览 8 评论
1917 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3158 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2215 浏览 5 评论
706浏览 1评论
597浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
480浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
609浏览 0评论
505浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-8 03:28 , Processed in 1.251985 second(s), Total 69, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号