ad71.c

来自「这是MICROCHIP 的PIC 系列单片机常用 的C语言编译器。特别对PIC1」· C语言 代码 · 共 45 行

C
45
字号
#pragma option v;
/*
   These routines may be adapted for any purpose when
   used with the MPC Code Development system.  No
   warranty is implied or given as to their usability
   for any purpose.

        (c) Copyright 1995,96

        Byte Craft Limited
        Waterloo, Ontario
        Canada N2J 4E4
        (519) 888-6911

        Sherif Abdel-Kader

  This example demonstrates the use of the A/D module on
  the PIC16C71. The technique is the same for all PIC16C7x
  having 4 channel A/Ds.

  This is part of the BCLINK example project and should only
  be compiled using DO-AD.BAT.
*/

#include <16c71.h>
#include <ad71.h>
#include <delay14.h>

void main()
{
  INIT_A2D(ANA4_VDD, FRC);  // RA0 - RA3 in analog mode
                            // Internal RC Oscillator
                            // A/D module ON
  TRISA = 0x0F;             // RA0 - RA3 in input mode
  while(1)
  {
     Select_A2D_Ch(Ch0);    // Select channel 0
     Delay_10xUs_4MHz(20);  // Delay 20 us
     TRISB = 0x00;
     PORTB = ConvertAD();   // Convert and display result
  }
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?