📄 adccalibrationdriverinit.c
字号:
//###########################################################################
//
// FILE: ADCcalibrationDriverInit.c
//
// TITLE: ADC Calibration Driver Initialization Function.
//
//###########################################################################
//
// Ver | dd-mmm-yyyy | Who | Description of changes
// =====|=============|=======|==============================================
// 1.0 | 20 Jun 2003 | AT/SD | Original Release.
// -----|-------------|-------|----------------------------------------------
// 1.1 | 26 Nov 2004 | AT | Fixed Bug In ADCcalibrationInitADC function.
// | | | Was incorrectly disabling ADC clock.
//
//###########################################################################
#include <DSP28_Device.h>
#include <ADCcalibrationDriver.h>
void ADCcalibrationDriverInit(ADC_CALIBRATION_DRIVER_VARS *v)
{
int i;
//----------------------------------------------------------------------
// Initialize structure variables:
//
v->RefHighChAddr = (void *) &AdcRegs.REF_HIGH_CH;
v->RefLowChAddr = (void *) &AdcRegs.REF_LOW_CH;
v->Ch0Addr = (void *) &AdcRegs.ADCRESULT0;
v->RefHighIdealCount = REF_HIGH_IDEAL_COUNT;
v->RefLowIdealCount = REF_LOW_IDEAL_COUNT;
v->Avg_RefLowActualCount = 0;
v->Avg_RefHighActualCount = 0;
v->CalGain = 0;
v->CalOffset = 0;
v->ch0 = 0;
v->ch1 = 0;
v->ch2 = 0;
v->ch3 = 0;
v->ch4 = 0;
v->ch5 = 0;
v->ch6 = 0;
v->ch7 = 0;
v->ch8 = 0;
v->ch9 = 0;
v->ch10 = 0;
v->ch11 = 0;
v->ch12 = 0;
v->ch13 = 0;
v->ch14 = 0;
v->ch15 = 0;
//----------------------------------------------------------------------
// Start ADC:
//
AdcRegs.ADCTRL2.bit.SOC_SEQ1=1;
//----------------------------------------------------------------------
// Wait for ADC to finish conversions (test INT1 flag):
//
while (AdcRegs.ADCST.bit.INT_SEQ1== 0){}
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;
for(i=0; i<100; i++)
//----------------------------------------------------------------------
// Pre-initialize ADC reference values:
//
v->Avg_RefHighActualCount=*(v->RefHighChAddr);
v->Avg_RefLowActualCount=*(v->RefLowChAddr);
}
//==========================================================================
// No more.
//==========================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -