完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
您好,我正在用PIC16F1829进行一个项目,我很难配置PORTC,似乎RC1、RC2、RC4、RC5和RC7不会进入低状态,它们被卡住一样高。结果来自proteus的模拟,PIC是SMD,我不能在实际应用中对它们进行测试,直到PCB完成。这是配置是否有类似的问题?我错过了一些配置吗?或者这只是一个模拟问题。所有其他端口引脚都在正确工作,只是这6个引脚被卡住了。
以上来自于百度翻译 以下为原文 Hello, i am working on a project with PIC16F1829 and i am having a hard time configurating PORTC, it seems that RC1, RC2, RC4, RC5 and RC7 won't go low state, they are stuck as high. The results are from a simulation in Proteus, the PIC's are smd and i can't test them in a real application until the PCB's are done. Here is the configuration void main() { C1ON_bit = C2ON_bit = 0; // disable comparators TRISC = 0x00; // all pins as output ANSELC = 0x00; // all pins digital LATC = 0x00; // pull all pins to low state } Did anyone had similar problems ? Did i miss some configurations ? Or maybe it is just a simulation issue. All other port pins are working correctly, just this 6 pin's are stuck. |
|
相关推荐
4个回答
|
|
你的主()函数不应该在一个嵌入式应用程序中退出。它应该包含一个无休止的循环,它要么永远地做一些动作,要么永远不做任何事情,阻止它到达函数的末尾。你所发布的代码将不断地重置。
以上来自于百度翻译 以下为原文 Your main() function should NEVER exit in an embedded application. It should contain an endless loop which either does some action forever, or nothing forever, to stop it reaching the end of the function. The code you posted will be continually resetting. |
|
|
|
我有一个循环,我只是不张贴整个代码,因为还有其他功能,我一直工作到这个奇怪的POTC问题。这里是完整的主要功能,缺少的功能只是做逻辑的东西,不使用任何外围模块。
以上来自于百度翻译 以下为原文 I have the loop, i just don't posted the whole code because there are other functions that i worked on until this weird PORTC problem. Here is the complete main function, the missing functions are just doing logical stuff without using any peripheral modules. #include "valveController.h" #include "display.h" #include "adc.h" unsigned volatile long millis = 0; void InitTimer0(){ OPTION_REG = 0x83; TMR0 = 6; INTCON = 0xA0; } void Interrupt(){ if (TMR0IF_bit){ TMR0IF_bit = 0; TMR0 = 6; millis++; } if (IOCAF.F0) { IOCAF.F0 = 0; INTCON.F0 = 0; rotarySwitchDetected(); } } void main() { C1ON_bit = C2ON_bit = 0; APFCON0 = 0x84; APFCON1 = 0x00; TRISB = 0xFF; LATB = 0x00; ANSELB = 0x00; TRISA = 0xFF; ANSELA = 0x4; TRISC = 0x00; ANSELC = 0x00; WPUC = 0x00; PORTC = 0x00; WPUA = 0xB; InitTimer0(); OPTION_REG.F7 = 0; // rotary switch IOCAN.F0 = 1; INTCON.F3 = 1; // ADC FVRCON = 0x82; ADC_Init(); while (1) { showDisplay(); checkButton(); readTemp(); handleValve(); } } |
|
|
|
OKY,这似乎是一个模拟错误,设置“WPUC=0x00”而不清除“WPUEN”迫使引脚高,这是没有意义的。将其设置为0x00应该关闭任何拖拉,而不清除“WPUEN”,它应该明确地不打开他们,即使他们是单独打开。因此,PIC的仿真模型似乎与WPUC寄存器有一定的问题,将其设置为任何值都会使POTCC管脚卡住。我将在模拟中使用外部拖拉,当我为真正的应用程序编译最终版本时,切换到内部的UPS。
以上来自于百度翻译 以下为原文 Okey, it seems to be a simulation error, setting "WPUC = 0x00" without clearing "WPUEN" forces the pins to high which makes no sense. Setting it to 0x00 should turn off any pull-ups, and without clearing "WPUEN" it should definitlly not turn them on even they are individually turned on. So it seems that the simulation model of the PIC has some issue with the "WPUC" register, setting it to any value makes the PORTC pin's to stuck. I will use external pull-ups in the simulation and switch to the internal one's when i will compile the final version for the real application. |
|
|
|
从源头上,我假设你正在使用CCS C.这总是值得一提的,因为这里大部分都是使用XC8。无论如何,我没有看到在发布的代码中有什么致命的,所以可能性是:(1)Proteus中的一个bug(不是未听到的)[2 ]你正在调用的一个函数。发布这些函数的代码。你试过不打电话给他们吗?即简单地替换超级环:(1);
以上来自于百度翻译 以下为原文 From the source, I assume you are using CCS C. That's always worth mentioning, as most here would be using XC8. Anyway, I'm not seeing anything fatal in the code posted, so the possibilities are: [1] A bug in Proteus (not unheard off) [2] One of the functions you are calling writing to PORTC. You didn't post the code for those functions. Have you tried simply not calling them? i.e. replace the super loop with simply: while (1); |
|
|
|
只有小组成员才能发言,加入小组>>
5243 浏览 9 评论
2035 浏览 8 评论
1955 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3208 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2258 浏览 5 评论
779浏览 1评论
672浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
598浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
682浏览 0评论
579浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 22:21 , Processed in 1.293710 second(s), Total 82, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号