亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? f34x_adc0_externalinput_mux.c

?? C8051F16位單片機程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
//-----------------------------------------------------------------------------
// F34x_ADC0_ExternalInput_Mux.c
//-----------------------------------------------------------------------------
// Copyright 2005 Silicon Laboratories, Inc.
// http://www.silabs.com
//
// This code example illustrates using the internal analog multiplexer to
// measure analog voltages on up to 8 different analog inputs.  Results are
// printed to a PC terminal program via the UART.
//
// The inputs are sequentially scanned, beginning with input 0 (P2.0), up
// to input number <ANALOG_INPUTS>-1 based on the values in <PIN_TABLE>.
//
//
// ADC Settling Time Requirements, Sampling Rate:
// ----------------------------------------------
//
// The total sample time per input is comprised of an input setting time
// (Tsettle), followed by a conversion time (Tconvert):
//
// Tsample  = Tsettle + Tconvert
//
// Settling and conversion times may overlap, as the ADC holds the value once
// conversion begins.  This program takes advantage of this to increase the
// settling time above the minimum required.  In other words, when
// converting the value from analog input Ain(n), the input mux is switched
// over to the next input Ain(n+1) to begin settling.
//
// |---Settling Ain(n)---|=Conversion Ain(n)=|
//                       |---Settling Ain(n+1)---|=Conversion Ain(n+1)=|
//                                               |---Settling Ain(n+2)---|
// ISR:  Timer 2         ^                       ^                       ^
// ISR:  ADC0                                ^                         ^
//
// The ADC input voltage must be allowed adequate time to settle before the
// conversion is made.  This settling depends on the external source
// impedance, internal mux impedance, and internal capacitance.
// Settling time is given by:
//
//                   | 2^n |
//    Tsettle =   ln | --- | * Rtotal * Csample
//                   | SA  |
//
// In this application, assume a 100kohm potentiometer as the voltage divider.
// The expression evaluates to:
//
//                   | 2^12 |
//    Tsettle =   ln | ---- | * 105e3 * 10e-12 = 10.2uS
//                   | 0.25 |
//
// In addition, one must allow at least 1.5 us after changing analog MUX
// inputs or PGA settings.  The settling time in this example, then, is
// dictated by the large external source resistance.
//
// The conversion is 16 periods of the SAR clock.  At 2.5 MHz,
// this time is 16 * 400nS = 6.4 uS.
//
//
// Tsample, minimum  = Tsettle + Tconvert
//                   = 10.2uS + 6.4uS
//                   = 16.6 uS
//
// Timer2 is set to change the MUX input and start a conversion every 20 us.
//
// General:
// --------
//
// The system is clocked using the internal 12MHz oscillator. Results are
// printed to the UART from a loop with the rate set by a delay based on
// Timer0. This loop periodically reads the ADC value from a global array,
// <RESULT>.
//
// The ADC makes repeated measurements at 20 us intervals based on Timer2.
// The end of each ADC conversion initiates an interrupt which calls an
// averaging function. <INT_DEC> samples are averaged, then the Result
// values updated.
//
// For each power of 4 of <INT_DEC>, you gain 1 bit of effective resolution.
// For example, <INT_DEC> = 256 gain you 4 bits of resolution: 4^4 = 256.
//
// The ADC input multiplexer is set for a single-ended input.  The example
// sequentially scans through the inputs, starting at P2.0.  <ANALOG_INPUTS>
// inputs are read.  The amplifier is set for unity gain so a voltage range of
// 0 to Vref (2.43V) may be measured.  Although voltages up to Vdd may be
// applied without damaging the device, only the range 0 to Vref may be
// measured by the ADC.
//
// A 100 kohm potentiometer may be connected as a voltage divider between
// VREF and AGND as shown below:
//
// ---------
//          |
//         o| AGND ----|
//         o| VREF ----|<-|
//         o| P2.x     |  |
//         o|    |        |
//         o|     --------
//         o|
//         o|
//         o|
//          |
// ---------
//
// How To Test:
//
// 1) Download code to a 'F34x device that is connected to a UART transceiver
// 2) Verify the TX and RX jumpers are populated on J3.
// 3) Connect a serial cable from the DB9 connector to a PC
// 4) On the PC, open HyperTerminal (or any other terminal program) and connect
//    to the COM port at <BAUDRATE> and 8-N-1
// 5) Connect a variable voltage source (between 0 and Vref) to the Port2 pins,
//    or a potentiometer voltage divider as shown above.
// 6) HyperTerminal will print the voltages measured by the device if
//    everything is working properly.  Note that some of the analog inputs are
//    floating and will return nonzero values.
//
// FID:            34X000092
// Target:         C8051F34x
// Tool chain:     Keil C51 7.50 / Keil EVAL C51
// Command Line:   None
//
// Release 1.0
//    -Initial Revision (SM / TP)
//    -19 OCT 2006
//


//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------

#include <C8051F340.h>                 // SFR declarations
#include <stdio.h>

//-----------------------------------------------------------------------------
// 16-bit SFR Definitions for 'F34x
//-----------------------------------------------------------------------------

sfr16 TMR2RL = 0xCA;                   // Timer2 reload value
sfr16 TMR2 = 0xCC;                     // Timer2 counter
sfr16 ADC0 = 0xBD;                     // 10-bit ADC0 result

//-----------------------------------------------------------------------------
// Global CONSTANTS
//-----------------------------------------------------------------------------

#define SYSCLK        12000000         // SYSCLK frequency in Hz
#define BAUDRATE      115200           // Baud rate of UART in bps
#define ANALOG_INPUTS 6                // Number of AIN pins to measure,
                                       // skipping the UART0 pins
#define INT_DEC       256              // Integrate and decimate ratio

#define TIMER0_RELOAD_HIGH  0          // Timer0 High register
#define TIMER0_RELOAD_LOW 255          // Timer0 Low register

//-----------------------------------------------------------------------------
// Function PROTOTYPES
//-----------------------------------------------------------------------------

void Oscillator_Init (void);
void Port_Init (void);
void Timer2_Init(void);
void ADC0_Init(void);
void UART0_Init (void);

void Timer0_wait(int ms);

//-----------------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------------

long RESULT[ANALOG_INPUTS];            // ADC0 decimated value, one for each
                                       // analog input

// The <PIN_MUX_TABLE> values are the values to be written to the AMX0P
// register to select the P2.<PIN_TABLE> port pins.
// For the 'F340, the AMX0P settings correspond to the following port pins:
//
//    AMX0P      Port Pin
//    0x00         P2.0
//    0x01         P2.1
//    0x02         P2.2
//    0x03         P2.3
//    0x04         P2.5
//    0x05         P2.6
//
unsigned char idata PIN_TABLE[ANALOG_INPUTS] = {0,1,2,3,5,6};
unsigned char idata PIN_MUX_TABLE[ANALOG_INPUTS] = {0,1,2,3,4,5};

unsigned char AMUX_INPUT = 0;          // Index of analog MUX inputs

//-----------------------------------------------------------------------------
// MAIN Routine
//-----------------------------------------------------------------------------
void main (void)
{
   unsigned char i;
   unsigned long measurement;

   PCA0MD &= ~0x40;                    // WDTE = 0 (clear watchdog timer
                                       // enable)

   Oscillator_Init ();                 // Initialize system clock to
                                       // 12MHz
   Port_Init ();                       // Initialize crossbar and GPIO
   Timer2_Init();                      // Init Timer2 to generate
                                       // overflows to trigger ADC
   UART0_Init();                       // Initialize UART0 for printf's
   ADC0_Init();                        // Initialize ADC0

   EA = 1;                             // Enable global interrupts
   while (1)
   {
      EA = 0;                          // Disable interrupts
      printf("\f");
      for(i = 0; i < ANALOG_INPUTS; i++)
      {
         // The 10-bit ADC value is averaged across INT_DEC measurements.
         // The result is then stored in RESULT, and is right-justified
         // The measured voltage applied to the port pins is then:
         //
         //                           Vref (mV)
         //   measurement (mV) =   --------------- * Result (bits)
         //                        (2^10)-1 (bits)

         measurement =  RESULT[i] * 2430 / 1023;
         printf("P2.%bu voltage: %4ld mV\n",PIN_TABLE[i],measurement);
      }
      EA = 1;                          // Re-enable interrupts

      Timer0_wait(25);                  // Wait before displaying new values
   }
}

//-----------------------------------------------------------------------------
// Initialization Subroutines
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// SYSCLK_Init
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// This routine initializes the system clock to use the internal 12MHz
// oscillator as its clock source.  Also enables missing clock detector reset.
//
void Oscillator_Init (void)
{
   OSCICN = 0x83;                      // Configure internal oscillator for
                                       // its highest frequency
   RSTSRC = 0x04;                      // Enable missing clock detector
}

//-----------------------------------------------------------------------------
// Port_Init
//-----------------------------------------------------------------------------
//

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产欧美一区二区精品性色| 日韩欧美123| 激情都市一区二区| 亚洲精品高清视频在线观看| 欧美一区二区三区系列电影| 北条麻妃国产九九精品视频| 免费在线成人网| 一区二区三区在线视频观看58 | 99riav久久精品riav| 日韩激情视频网站| 亚洲精品乱码久久久久| 国产日韩精品视频一区| 欧美一级黄色大片| 欧美在线一二三四区| 国产69精品久久99不卡| 久久精品国产一区二区| 亚洲综合久久久久| 国产麻豆精品95视频| 亚洲国产sm捆绑调教视频| 欧美激情综合五月色丁香| 欧美第一区第二区| 88在线观看91蜜桃国自产| 在线观看国产精品网站| 91色综合久久久久婷婷| 不卡一区二区中文字幕| 国产成人亚洲精品青草天美| 美女看a上一区| 日本人妖一区二区| 五月婷婷色综合| 五月综合激情网| 亚洲成人手机在线| 亚洲一二三级电影| 亚洲国产婷婷综合在线精品| 怡红院av一区二区三区| 综合亚洲深深色噜噜狠狠网站| 久久久三级国产网站| 亚洲精品一区二区三区影院| 日韩欧美中文字幕公布| 日韩美女一区二区三区| 日韩欧美国产综合一区 | 亚洲成人激情综合网| 一区二区三区在线观看网站| 亚洲色图在线看| 一区二区视频在线| 亚洲影视资源网| 亚洲午夜精品一区二区三区他趣| 亚洲精品欧美在线| 亚洲午夜影视影院在线观看| 亚洲在线一区二区三区| 亚洲高清不卡在线观看| 天天免费综合色| 蜜臂av日日欢夜夜爽一区| 韩国视频一区二区| 国产精品一二三区| 99久久伊人网影院| 欧美综合亚洲图片综合区| 欧美婷婷六月丁香综合色| 欧美日韩精品欧美日韩精品| 3d动漫精品啪啪一区二区竹菊| 在线播放亚洲一区| 久久久www免费人成精品| 国产精品乱人伦| 一区二区理论电影在线观看| 亚洲h精品动漫在线观看| 免费看欧美女人艹b| 国产一区二区三区观看| www.日韩av| 欧美日产在线观看| 26uuu精品一区二区三区四区在线| 久久精品欧美一区二区三区不卡| 国产精品拍天天在线| 亚洲黄色小说网站| 精品午夜一区二区三区在线观看| 国产精品18久久久久久久网站| 91免费视频观看| 在线电影欧美成精品| 久久女同精品一区二区| 一区二区三区中文在线观看| 美腿丝袜在线亚洲一区| av综合在线播放| 欧美二区三区91| 中文字幕在线一区| 日韩精品午夜视频| 成人伦理片在线| 日韩亚洲欧美一区二区三区| 中文字幕在线观看一区| 日韩激情一二三区| 99久久久久久99| 欧美大白屁股肥臀xxxxxx| 亚洲欧洲av在线| 日韩二区在线观看| 91在线视频免费91| 精品福利一区二区三区免费视频| 亚洲欧美日韩精品久久久久| 国产成人在线视频免费播放| 亚洲毛片av在线| 无码av中文一区二区三区桃花岛| 久久99国内精品| 日本精品免费观看高清观看| 久久精品免视看| 丝袜国产日韩另类美女| 白白色 亚洲乱淫| 欧美精品一区二区三区一线天视频 | 欧美日韩一区二区在线观看视频| 精品国产一区二区三区四区四| 夜夜嗨av一区二区三区中文字幕| 国产精品99久久久久| 7878成人国产在线观看| 亚洲人快播电影网| 国产1区2区3区精品美女| 日韩欧美国产三级电影视频| 一个色综合av| 91老师片黄在线观看| 国产午夜精品一区二区三区视频 | 婷婷久久综合九色国产成人 | 日本韩国精品在线| 国产精品美女视频| 国产美女视频一区| 日韩一区二区三区高清免费看看 | 亚洲一区二区三区视频在线| 成人精品国产一区二区4080| 精品久久久久久综合日本欧美| 午夜日韩在线电影| 欧美日韩精品一区二区| 亚洲品质自拍视频网站| 成人黄色777网| 久久久91精品国产一区二区三区| 麻豆精品视频在线观看| 日韩一区二区三区高清免费看看| 日韩一区精品字幕| 欧美日本乱大交xxxxx| 亚洲午夜一区二区三区| 在线亚洲一区二区| 亚洲午夜av在线| 欧美三区在线观看| 亚洲二区视频在线| 欧美日韩另类一区| 亚洲国产一区在线观看| 欧美视频中文字幕| 亚洲成人综合视频| 欧美一区二区三区喷汁尤物| 免费高清成人在线| 亚洲精品在线观| 国产成人综合在线播放| 中文字幕欧美国产| 99re这里只有精品首页| 亚洲欧美国产毛片在线| 91福利视频网站| 亚洲不卡在线观看| 日韩一卡二卡三卡国产欧美| 久久精品理论片| 欧美激情综合网| 色婷婷香蕉在线一区二区| 亚洲成人自拍一区| 日韩欧美自拍偷拍| 国产九色sp调教91| 亚洲天堂精品在线观看| 欧美吻胸吃奶大尺度电影| 日韩电影免费一区| 久久综合九色综合欧美98| 国产不卡视频一区| 一区二区三区成人| 欧美一区二区三区不卡| 国内成+人亚洲+欧美+综合在线| 久久精品视频网| 日本道在线观看一区二区| 偷拍亚洲欧洲综合| 久久亚洲一区二区三区四区| 成人av动漫在线| 午夜视频一区在线观看| 久久午夜羞羞影院免费观看| 国产suv精品一区二区三区| 亚洲色图一区二区| 日韩欧美一级在线播放| 成人精品视频.| 午夜久久电影网| 欧美国产在线观看| 欧美日韩性生活| 成熟亚洲日本毛茸茸凸凹| 夜夜嗨av一区二区三区网页| 欧美精品一区二区蜜臀亚洲| fc2成人免费人成在线观看播放| 亚洲成a人v欧美综合天堂下载 | 天天影视色香欲综合网老头| 欧美精品一区二区三区蜜桃视频| www.欧美色图| 精品一区二区三区影院在线午夜| 亚洲欧洲精品一区二区三区 | 欧美猛男男办公室激情| 国产91精品入口| 视频一区二区中文字幕| 国产精品久久久久一区| 91精品国产综合久久香蕉的特点| 丰满放荡岳乱妇91ww| 亚洲成av人在线观看| 国产精品入口麻豆九色| 精品少妇一区二区三区视频免付费 | 91小视频免费观看| 久久精品二区亚洲w码| 亚洲免费在线观看视频|