?? adc.c
字號:
//****************************************************************************
// @Module Analog / Digital Converter (ADC)
// @Filename ADC.C
// @Project HVAC.dav
//----------------------------------------------------------------------------
// @Controller Infineon XC866-2FR
//
// @Compiler Keil
//
// @Codegenerator 1.7
//
// @Description: This file contains functions that use the ADC module.
//
//----------------------------------------------------------------------------
// @Date 2008-4-15 19:56:02
//
//****************************************************************************
// USER CODE BEGIN (ADC_General,1)
// USER CODE END
//****************************************************************************
// @Project Includes
//****************************************************************************
#include "MAIN.H"
// USER CODE BEGIN (ADC_General,2)
// USER CODE END
//****************************************************************************
// @Macros
//****************************************************************************
// USER CODE BEGIN (ADC_General,3)
// USER CODE END
//****************************************************************************
// @Defines
//****************************************************************************
// USER CODE BEGIN (ADC_General,4)
// USER CODE END
//****************************************************************************
// @Typedefs
//****************************************************************************
// USER CODE BEGIN (ADC_General,5)
// USER CODE END
//****************************************************************************
// @Imported Global Variables
//****************************************************************************
// USER CODE BEGIN (ADC_General,6)
// USER CODE END
//****************************************************************************
// @Global Variables
//****************************************************************************
// USER CODE BEGIN (ADC_General,7)
// USER CODE END
//****************************************************************************
// @External Prototypes
//****************************************************************************
// USER CODE BEGIN (ADC_General,8)
// USER CODE END
//****************************************************************************
// @Prototypes Of Local Functions
//****************************************************************************
// USER CODE BEGIN (ADC_General,9)
// USER CODE END
//****************************************************************************
// @Function void ADC_vInit(void)
//
//----------------------------------------------------------------------------
// @Description This is the initialization function of the ADC function
// library. It is assumed that the SFRs used by this library
// are in their reset state.
//
// Following SFR fields will be initialized:
// GLOBCTR - Global Control
// PRAR - Priority and Arbitration Register
// ETRCR - External Trigger Control Register
// CHCTRx - Channel Control Register x
// RCRx - Result Control Register x
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters None
//
//----------------------------------------------------------------------------
// @Date 2008-4-15
//
//****************************************************************************
// USER CODE BEGIN (ADC_Init,1)
// USER CODE END
void ADC_vInit(void)
{
// USER CODE BEGIN (ADC_Init,2)
// USER CODE END
/// -----------------------------------------------------------------------
/// Configuration of Global Control:
/// -----------------------------------------------------------------------
/// - the ADC module clock is enabled
/// - the ADC module clock = 26.67 MHz
///
/// - the result is 10 bits wide
/// --- Conversion Timing -----------------
/// - conversion time (CTC) = 01.50 us
/// - Configure global control functions
SFR_PAGE(_ad0, noSST); // switch to page 0
ADC_GLOBCTR = 0x10; // load global control register
/// -----------------------------------------------------------------------
/// Configuration of Priority and Arbitration:
/// -----------------------------------------------------------------------
/// - the priority of request source 0 is high
/// - the wait-for-start mode is selected for source 0
/// - the priority of request source 1 is low
/// - the wait-for-start mode is selected for source 1
/// - the arbitration started by pending conversion request is selected
/// - Arbitration Slot 0 is enabled
/// - Arbitration Slot 1 is disabled
ADC_PRAR = 0x51; // load Priority and Arbitration register
SFR_PAGE(_ad1, noSST); // switch to page 1
/// -----------------------------------------------------------------------
/// Configuration of Channel Control Registers:
/// -----------------------------------------------------------------------
/// Configuration of Channel 0
/// - the result register0 is selected
/// - the limit check 0 is selected
ADC_CHCTR0 = 0x00; // load channel control register
/// Configuration of Channel 1
/// - the result register0 is selected
/// - the limit check 0 is selected
ADC_CHCTR1 = 0x00; // load channel control register
/// Configuration of Channel 2
/// - the result register0 is selected
/// - the limit check 0 is selected
ADC_CHCTR2 = 0x00; // load channel control register
/// Configuration of Channel 3
/// - the result register0 is selected
/// - the limit check 0 is selected
ADC_CHCTR3 = 0x00; // load channel control register
/// Configuration of Channel 4
/// - the result register0 is selected
/// - the limit check 0 is selected
ADC_CHCTR4 = 0x00; // load channel control register
/// Configuration of Channel 5
/// - the result register0 is selected
/// - the limit check 0 is selected
ADC_CHCTR5 = 0x00; // load channel control register
SFR_PAGE(_ad0, noSST); // switch to page 0
/// -----------------------------------------------------------------------
/// Configuration of Sample Time Control:
/// -----------------------------------------------------------------------
ADC_INPCR0 = 0x00; // load input class register
SFR_PAGE(_ad4, noSST); // switch to page 4
/// -----------------------------------------------------------------------
/// Configuration of Result Control Registers:
/// -----------------------------------------------------------------------
/// Configuration of Result Control Register 0
/// - the data reduction filter is disabled
/// - the event interrupt is disabled
/// - the wait-for-read mode is enabled
/// - the VF reset by read access to RESRxH/RESRAxH
ADC_RCR0 = 0xC0; // load result control register 0
/// Configuration of Result Control Register 1
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -