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

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

?? f32x_adc0_externalinput_mux.c

?? 8051 SPI code ans 8051 ADC code
?? C
?? 第 1 頁 / 共 2 頁
字號:
//-----------------------------------------------------------------------------
// F32x_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 (P1.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 P1.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| P1.x     |  |
//         o|    |        |
//         o|     --------
//         o|
//         o|
//         o|
//          |
// ---------
//
// How To Test:
//
// 1) Download code to a 'F32x 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 Port1 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:            32X000091
// Target:         C8051F32x
// Tool chain:     Keil C51 7.50 / Keil EVAL C51
// Command Line:   None
//
// Release 1.0
//    -Initial Revision (SM / TP)
//    -19 OCT 2006
//


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

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

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

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

// Port1 ADC Inputs
unsigned char idata PIN_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("P1.%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
//-----------------------------------------------------------------------------
//
// Return Value : None
// Parameters   : None
//
// Configure the Crossbar and GPIO ports.
//
// P0.4 - UART TX (push-pull)

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品欧美一级免费| 日韩欧美中文字幕公布| 国产视频视频一区| 国产jizzjizz一区二区| 亚洲女同ⅹxx女同tv| 欧美丰满少妇xxxbbb| 国产成人免费视频精品含羞草妖精| 国产精品久久久久一区 | 一区2区3区在线看| 3d成人h动漫网站入口| 国产精品一区二区黑丝| 亚洲综合色噜噜狠狠| 久久免费的精品国产v∧| 91丨九色丨蝌蚪丨老版| 久久99久久精品| 亚洲国产成人va在线观看天堂| 欧美va亚洲va国产综合| 欧美亚洲图片小说| 成人性生交大片免费看中文网站| 亚洲chinese男男1069| 久久精品日产第一区二区三区高清版 | 精品国产乱码久久久久久久久| 97精品国产97久久久久久久久久久久| 日本不卡的三区四区五区| 综合久久一区二区三区| 中文字幕不卡的av| 精品久久久久一区| 中文字幕免费不卡| 亚洲一区在线视频| 久久av资源站| 免费成人在线观看视频| 国产一区二区中文字幕| 美女mm1313爽爽久久久蜜臀| 亚洲图片欧美色图| 精油按摩中文字幕久久| av在线这里只有精品| 国产一区二区在线观看视频| 97se亚洲国产综合自在线 | 国产在线视频精品一区| 肉丝袜脚交视频一区二区| 亚洲一区中文日韩| 国产盗摄视频一区二区三区| 欧美午夜一区二区三区免费大片| 26uuu精品一区二区| 久久一日本道色综合| 亚洲蜜臀av乱码久久精品| 国产一区高清在线| 欧美肥妇bbw| 一个色综合av| 成人黄色国产精品网站大全在线免费观看 | 欧美性感一区二区三区| 国产亚洲污的网站| 另类综合日韩欧美亚洲| 欧美午夜精品久久久久久孕妇 | 亚洲精品久久久蜜桃| 国产精品久久久久久一区二区三区| 亚洲电影一级黄| a级高清视频欧美日韩| 久久久精品tv| 日本伊人色综合网| 国产精品99久久久久久似苏梦涵| 欧美精品xxxxbbbb| 一区二区三区免费| 91亚洲午夜精品久久久久久| 国产日韩影视精品| 亚洲免费观看高清完整版在线观看熊| 国产美女娇喘av呻吟久久| 欧美一级高清片| 日韩 欧美一区二区三区| 在线观看日韩电影| 精品国产a毛片| 老汉av免费一区二区三区 | yourporn久久国产精品| 久久丝袜美腿综合| 国产精品资源网站| 国产亲近乱来精品视频| 国产麻豆精品95视频| 久久久高清一区二区三区| 国产在线观看免费一区| 国产日韩欧美不卡在线| 高清不卡一区二区| 亚洲欧美偷拍另类a∨色屁股| 成人黄动漫网站免费app| 国产精品福利一区二区三区| 成人av影视在线观看| 中文字幕不卡一区| 色婷婷精品久久二区二区蜜臀av| 欧美一级片在线| **网站欧美大片在线观看| 青青草一区二区三区| 精品国产亚洲在线| 国产东北露脸精品视频| 亚洲免费视频成人| 91精品综合久久久久久| 国产中文字幕一区| 中文字幕巨乱亚洲| 欧美三级中文字幕在线观看| 国产精品你懂的| 欧洲一区二区三区免费视频| 午夜精品福利一区二区蜜股av| 色乱码一区二区三区88| 国产精品视频看| 色女孩综合影院| 麻豆久久久久久| 国产精品国产三级国产普通话99 | 午夜久久久久久电影| 久久这里只精品最新地址| 99免费精品视频| 午夜视频一区二区| 国产清纯美女被跳蛋高潮一区二区久久w| eeuss鲁片一区二区三区在线看| 午夜视黄欧洲亚洲| 国产精品久久久久久久第一福利| 欧美日韩在线播放一区| 国产精品99久久久久久久女警| 一区二区三区中文字幕| 久久蜜臀精品av| 欧美另类videos死尸| 东方欧美亚洲色图在线| 日韩精品乱码免费| 亚洲欧洲99久久| 久久色中文字幕| 欧美不卡一区二区三区四区| 91在线国产福利| 国产成人综合自拍| 美日韩一级片在线观看| 亚洲综合精品久久| 中文字幕一区二区三中文字幕| 欧美一区二区视频在线观看| www.在线欧美| 成人免费av资源| 岛国精品一区二区| 国产精品一区二区x88av| 日韩不卡一区二区| 亚洲综合色视频| 亚洲另类中文字| 自拍av一区二区三区| 亚洲国产高清在线| 国产三级一区二区三区| 日韩三级免费观看| 91精品婷婷国产综合久久| 欧美性受xxxx黑人xyx| 91色porny| 一本色道久久综合亚洲aⅴ蜜桃| 福利一区二区在线| 国产精品亚洲成人| 国产成人精品亚洲日本在线桃色| 国产在线一区观看| 国产成人高清视频| 国产成人av影院| 成人黄色小视频在线观看| www.色精品| 97se亚洲国产综合自在线不卡| 91日韩在线专区| av一区二区三区| 色哟哟日韩精品| 欧美体内she精视频| 欧美精品色一区二区三区| 8x福利精品第一导航| 欧美精品丝袜中出| 精品久久免费看| 中文一区二区在线观看| 中文字幕日韩一区二区| 亚洲欧美日韩系列| 亚洲国产精品自拍| 老司机精品视频在线| 国产精品自拍在线| av在线一区二区三区| 在线观看视频一区| 欧美videossexotv100| 日本一区二区在线不卡| 亚洲人精品一区| 日韩av不卡一区二区| 国产成人啪免费观看软件| 9色porny自拍视频一区二区| 91黄视频在线| 欧美成人午夜电影| 亚洲国产精品ⅴa在线观看| 一区二区三区毛片| 国内成人免费视频| 在线视频欧美区| 精品国产a毛片| 亚洲在线免费播放| 国产精品一区二区在线播放| 在线精品国精品国产尤物884a| 欧美精品乱码久久久久久| 国产日产精品1区| 婷婷开心激情综合| www.成人在线| 精品国精品自拍自在线| 亚洲精品国产一区二区三区四区在线| 爽好久久久欧美精品| 99久久综合99久久综合网站| 欧美另类变人与禽xxxxx| 国产精品高潮久久久久无| 久久国产婷婷国产香蕉| 在线一区二区三区四区| 久久久久国产精品免费免费搜索| 亚洲一区二区三区国产| 粉嫩av一区二区三区|