搜索
bottom↓
回复: 5

第一次使用16F887发现AD转换特别慢,估计》100ms吧,如何解决?

[复制链接]

出0入0汤圆

发表于 2008-4-9 08:09:09 | 显示全部楼层 |阅读模式
第一次使用16F887发现AD转换特别慢,估计》100ms吧,通过数码管能够感觉出来,改了几次程序依旧,我感觉PIC的芯片没有问题的,估计是程序的问题。但又不知道那的原因,大家帮帮忙?

以下蓝色文字由站长:armok 于:2008-04-09,09:57:13 加入。
你的原标题:“<font color=black>求助16F887AD转换?
” 不合符规定。请更改成能说明帖子大意的标题
试想一下,如果本论坛的帖子标题清一色的‘帮助!’,‘ADC求救!’等笼统的标题,你在阅读的过程中会造成许多麻烦。
所以本论坛规定:一定要起一个能说明帖子大意的标题。不允许“关于 AVR 的 ADC 使用!”这种笼统标题。作为标题,必须说明清楚:
 ①你是在请教问题,还是在介绍有关的知识?
 ②ADC的问题有许多,你是想说那方面的内容?
注意以上两点,标题应该改成如:“请教:ADC 可以不使用中断吗?”。
起一个能说明帖子大意的标题,除了减轻我们的帖子分类整理工作,还方便其它人阅读,节省大家的时间。
注:使用合格的标题,对你来说只是举手之劳,但却会为我们的管理工作提供很大的便利。谢谢你的支持。

出0入0汤圆

发表于 2008-4-9 08:33:51 | 显示全部楼层
呵是不是你数码管的刷新慢了。最好程序放出来

出0入0汤圆

 楼主| 发表于 2008-4-9 08:40:36 | 显示全部楼层
不会的,很快的<10ms的。不好意思今天是传不上来了。在家里的电脑上了。是不是有什么特殊设置?(16F887)

出0入0汤圆

发表于 2008-4-9 09:53:25 | 显示全部楼层
是不是ADCS1:ADCS0设置,我不知你是用ASM还是C。给你一个CCSC的例子
/////////////////////////////////////////////////////////////////////////
////                          EX_ADMM.C                              ////
////                                                                 ////
////  This program displays the min and max of 30 A/D samples over   ////
////  the RS-232 interface.  The process is repeated forever.        ////
////                                                                 ////
////  If required configure the CCS prototype card as follows:       ////
////     Insert jumper from output of POT to pin A5                  ////
////     Use a 10K POT to vary the voltage.                          ////
////                                                                 ////
////  Jumpers:                                                       ////
////     PCM,PCH    pin C7 to RS232 RX, pin C6 to RS232 TX           ////
////     PCD        none                                             ////
////                                                                 ////
////  This example will work with the PCM, PCH, and PCD compilers.   ////
////  The following conditional compilation lines are used to        ////
////  include a valid device for each compiler.  Change the device,  ////
////  clock and RS232 pins for your hardware if needed.              ////
/////////////////////////////////////////////////////////////////////////
////        (C) Copyright 1996,2007 Custom Computer Services         ////
//// This source code may only be used by licensed users of the CCS  ////
//// C compiler.  This source code may only be distributed to other  ////
//// licensed users of the CCS C compiler.  No other use,            ////
//// reproduction or distribution is permitted without written       ////
//// permission.  Derivative programs created using this software    ////
//// in object code form are not restricted in any way.              ////
/////////////////////////////////////////////////////////////////////////


#if defined(__PCM__)                           // Preprocessor directive that chooses the compiler
#include <16F877.h>                           // Preprocessor directive that selects the chip
#fuses HS,NOWDT,NOPROTECT,NOLVP                // Preprocessor directive that defines the chip fuses
#use delay(clock=20000000)                     // Preprocessor directive that specifies clock speed
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7) // Preprocessor directive that includes RS232 libraries

#elif defined(__PCH__)
#include <18F452.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#elif defined(__PCD__)
#include <30F2010.h>
#fuses HS,NOWDT
#device ADC=8
#use delay(clock=20000000)
#use rs232(baud=9600, UART1A)
#endif

void main() {

   unsigned int8 i, value, min, max;

   printf("Sampling:");                      // Printf function included in RS232 library

   #ifdef __PCD__
   setup_adc_ports(sAN0);                    // Built-in A/D setup function
   #else
   setup_adc_ports(AN0);
   #endif
   
   setup_adc(ADC_CLOCK_INTERNAL);            // Built-in A/D setup function
   set_adc_channel(0);                       // Built-in A/D setup function

   do {
      min=255;
      max=0;
      for(i=0; i<=30; ++i) {
         delay_ms(100);                      // Built-in delay function
         value = read_adc();                 // Built-in A/D read function
         if(value<min)
            min=value;
         if(value>max)
            max=value;
      }
      
      printf("\r\nMin: %2X  Max: %2X\n\r",min,max);     
   } while (TRUE);
}

出0入0汤圆

发表于 2008-4-9 21:15:08 | 显示全部楼层
再看看手册吧   程序的问题

出0入0汤圆

 楼主| 发表于 2008-4-10 08:19:22 | 显示全部楼层
帮帮分析下:

void main (void)
               
{
clr_RAM( );
//AD初试化
ADCON1=0x80;               
ADCON0=0x01;
ADIF=0;
PEIE=1;
GIE=1;       
DelayUs(50);
GODONE=1;
while(1)
{
   //处理显示


}
}

void interrupt int_int(void)
{
if(ADIF==1)
{
ADIF=0;       
adresult.adr[0]=ADRESL;
adresult.adr[1]=ADRESH;
AD_DATA1=adresult.ad_pp;       
GODONE=1;                       
}
}
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-2 19:47

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表