完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,每个人谁回答我的问题和其他SI不能重放以前的主题,因为访问拒绝(我已经尝试削减文本记事本和粘贴来回)感谢您的所有建议,我只是想配置I2C通信设备,所以我读数据表页回到这个页面,我会尝试找到其他的解决方案。回到这个主题,我终于得到了PCB板,我试图点燃LED(连接到RC4),并不能使它明亮。设备:16F1824ID:XIDIDV3.60编译器:XC8 V1.41:这里是我的代码:实际上,我认为我不需要使用while循环来防止EX。引入主函数,因为RC4已经设置好了吗?
以上来自于百度翻译 以下为原文 Hi, every kind person who's been answering my questions and others I can't replay previous theme because of access denied (I've tried to cut texts to notepad and paste back and forth) Thanks for your all suggestions, I just want to configure the I2C to communicate to devices, so I read datasheet page by page, I will try to find some other solutions. Back to this theme, I finally got the PCB board, I was trying to light the LED(connected to RC4) and can't make it bright. device: 16F1824 IDE: X IDE v3.60 compiler: XC8 v1.41 Here is my code: #include #include #include // #pragma config CONFIG1 = 0b0000111101000100 #pragma config CONFIG2 = 0b0000111011111111 int main(int argc, char** argv) { TRISC=0x00; LATCbits.LATC4 = 1; while(1); } Actually I think I don't need to use while loop to prevent exiting the main function, because RC4 is already set, correct? |
|
相关推荐
8个回答
|
|
我尝试用IDE设置配置词,然后删除“语法”,它的工作方式是一种错误的设置方式。
以上来自于百度翻译 以下为原文 I tried to set configuration word by IDE and then delete #pragma, it works My setting way is a wrong setting way |
|
|
|
如果您使用MPLAB X,它将允许您设置配置文件,也可以为您生成代码,以便可以粘贴到源代码中。不确定你在哪里得到上面的…
以上来自于百度翻译 以下为原文 If you use MPLAB X, it will let you set the Configs and also generate code for you, that you can paste in your sources. Not sure where you got those above... |
|
|
|
对CinziaG:是的,这就是我后来做的。你的意思是“你在哪里得到上面的”?
以上来自于百度翻译 以下为原文 To CinziaG: Yes, that is what I did later on. What do you mean"where you got those above"? |
|
|
|
这些
以上来自于百度翻译 以下为原文 These #pragma config CONFIG1 = 0b0000111101000100 #pragma config CONFIG2 = 0b0000111011111111 are/would be a very bad way of telling the CONFIG values |
|
|
|
在你需要它们之前,不要包含这些(如果有的话),这是设置配置比特的最坏的可能方式。如果你正在使用XC8,那么替换它,在PIC中没有操作系统,所以没有命令行作为参数接受,也没有返回值。永远不要让一个嵌入式程序退出主函数。你的代码将从头开始重新启动,导致非常混乱的行为。
以上来自于百度翻译 以下为原文 Don't include these until you need them (if ever) #include #include As already mentioned, this is the worst possible way to set the config bits. #pragma config CONFIG1 = 0b0000111101000100 #pragma config CONFIG2 = 0b0000111011111111 If you are using XC8, then replace this int main(int argc, char** argv) { with void main(void) { There is no operating syste, in a PIC, so there is no command line to accept as a parameter, and nothing to return a value to. Never, never, never let an embedded program exit the main function. Your code will just restart from the beginning again, causing very confusing behaviour. |
|
|
|
至于你的LED不发光的问题,你是如何布线的?一个常见的问题是LED的方向不对。测试这个方法的方法是不连接LED并确保引脚变高(假设LED /电阻器的另一侧是接地)。在将LED /电阻器连接到引脚之前,将其连接到VCC,并确保其亮起。如果没有,那么你可能有错误的方式周围的LED。当它工作,连接LED /电阻器回到引脚,然后再试一次。苏珊
以上来自于百度翻译 以下为原文 As for your problem about the LED not lighting, how have you got it wired up? One common problem is to have the LED the wrong way around. The way to test this is to not connect the LED and make sure that the pin is going high (assuming the other side of the LED/resistor is to ground). Before you connect the LED/Resistor to back to the pin, connect it to Vcc and make sure that it lights then. If not then you may have the LED in the wrong way around. When that works, connect the LED/Resistor back to the pin and try again. Susan |
|
|
|
如果你有一个电压表,检查RC4管脚上的电压。我相信,芯片是5VDC,所以如果输出是,在引脚和直流接地(0V)之间的电压应该是大约5VDC或无论PIC电源电压是什么。如果引脚上的电压为5VDC,则检查您的布线和LED极性。此外,您的while循环应该有一些括号,即:(1){}如果括号中有任何代码,则将重复执行。而且绝对遵循QHB的建议与主循环。
以上来自于百度翻译 以下为原文 If you have a voltmeter, check the voltage on the RC4 pin. I believe that chip is 5VDC, so if the output is on, the voltage between the pin and DC ground (0V) should be about 5VDC or whatever the PIC supply voltage is. If the voltage at the pin is 5VDC, then check your wiring and LED polarity. Also, your while loop should have some brackets, i.e.: while(1) {} If there is any code in the brackets, that will be executed repeatedly. And definitely follow qhb's advice with the main loop. |
|
|
|
为什么?它只是一个“不做”循环,在主体()的末尾。(1)完全有效。尾部半冒号终止语句。
以上来自于百度翻译 以下为原文 Why? It's just a "do nothing" loop at the end of main(). while(1); is perfectly valid to do that. The trailing semi-colon terminates the statement. |
|
|
|
只有小组成员才能发言,加入小组>>
5166 浏览 9 评论
2000 浏览 8 评论
1929 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3175 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2227 浏览 5 评论
736浏览 1评论
619浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
507浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
633浏览 0评论
530浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-25 09:57 , Processed in 1.364008 second(s), Total 62, Slave 56 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号