完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
我有以下代码用于ADC的PIC18F45 K22。它不起作用。有人看到什么错误吗?我有锅。连接在AN1上。
以上来自于百度翻译 以下为原文 I have following code for ADC for my PIC18F45K22. It is not working. Does anyone see any mistake? I have Pot. Connected on AN1. #include #include #include "adc.h" #include "newfile1.h" #include "delays.h" unsigned int out; void main() { // set PORTB to be digital output TRISB = 0; TRISC = 0; TRISA=0xFF; //Analog input // Turn OFF LEDs on PORTB LATB = 0; LATC = 0; //ANSELAbits.ANSA1 =1; //Analog select SetChanADC(ADC_CH1); OpenADC(ADC_FOSC_RC & ADC_RIGHT_JUST & ADC_12_TAD, ADC_CH1 & ADC_INT_OFF ,ADC_REF_VDD_VREFPLUS); Delay10TCYx(0x20); while(1){ ConvertADC(); Delay10TCYx(0x20); while (BusyADC()); ReadADC(); Delay10TCYx(0x20); LATC=ADRESL; LATB=ADRESH; Delay10TCYx(0x20); } CloseADC(); } |
|
相关推荐
7个回答
|
|
|
“不工作”是什么意思?不会编译?不会跑?运行,但带来意外的结果?
以上来自于百度翻译 以下为原文 What does "not working" mean? Won't compile? Won't run? Runs, but gives unexpected results? |
|
|
|
|
|
我看不到港口灯的变化,因为我增加/降低了锅。编译/编译/运行威尔斯。
以上来自于百度翻译 以下为原文 I can't see the change on the port LEDs as I increase/Decrees the pot. The compilation/Built/ runs wells. |
|
|
|
|
|
看起来不错——不需要延迟,并且SetChan被OpenADC覆盖,但是可以。PIC运行吗?配置设置?(请注意,不必包含PIC的特定包含文件)
以上来自于百度翻译 以下为原文 Looks good enough - the delays are not needed and the SetChan is overridden by OpenADC, but ok. Is the PIC running at all? CONFIG settings? (note also that there's no need to include the PIC's specific include file) |
|
|
|
|
|
配置设置在哪里?正如CinziaG建议的,我怀疑你的PIC根本没有运行。你应该先慢慢地闪烁一个LED,以确认它是否工作,然后再试着读ADC。
以上来自于百度翻译 以下为原文 Where are the CONFIG settings? As CinziaG suggested, I suspect your PIC is not running at all. You should start by just slowly flashing an LED first, to confirm that works, before trying to read the ADC. |
|
|
|
|
|
哪种版本的MPLAB?MPLAB8允许您在IDE中设置CONFIG设置。MPLABX要求您将它们放入源代码中。
以上来自于百度翻译 以下为原文 Which version of MPLAB? MPLAB8 lets you set the CONFIG settings in the IDE. MPLABX requires you to put them into your source code. |
|
|
|
|
|
哦,好的,那么我几乎可以确定OpenADC()调用有问题。这些参数在C18中从来都不清楚,我想它们仍然不在XC中。你应该尝试通过它的寄存器设置ADC -这是BTW肯定QHB的建议。
以上来自于百度翻译 以下为原文 Oh ok, then I am almost sure that there's something wrong in your OpenADC() call. Those parameters were never clear in C18 and I suppose they still aren't in XC. You should try setting the ADC via its registers - which is btw for sure what QHB would advice |
|
|
|
|
|
史,我只看到一个“去这里,去那里”……这些电话的来源在哪里?定义和指令在哪里?杰拉尔德---
以上来自于百度翻译 以下为原文 s Hi, I just see a "go here, go there" .... Where are the sources of these calls? Where are the definitions also the directives? Gerald --- |
|
|
|
|
只有小组成员才能发言,加入小组>>
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
490 浏览 0 评论
5806 浏览 9 评论
2346 浏览 8 评论
2234 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3541 浏览 3 评论
1146浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
1115浏览 1评论
我是Microchip 的代理商,有PIC16F1829T-I/SS 技术问题可以咨询我,微信:A-chip-Ti
883浏览 1评论
MPLAB X IDE V6.25版本怎么对bootloader和应用程序进行烧录
490浏览 0评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-9 22:37 , Processed in 0.752714 second(s), Total 84, Slave 67 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
627