XADC內(nèi)嵌在PS端,允許CPU或其他主機連接XADC,而不用使用PL端。XADC最大采樣率為1MSPS,精度為12bits,內(nèi)置電壓和溫度傳感器,可監(jiān)測芯片的電壓及溫度信息。電壓傳感器可監(jiān)測芯片的VCCINT,VCCAUX,VCCBRAM等,VP_0和VN_0為一對專用的ADC模擬輸入口。VAUXP[*]和VAUXN[*]也是ADC輸入口,但是不用作ADC輸入口時,可用作普通IO使用。
intXAdcPolledPrintfExample(u16 XAdcDeviceId)
{
intStatus;
XAdcPs_Config *ConfigPtr;
u32 TempRawData;
u32 VccPintRawData;
u32 VccPauxRawData;
u32 VccPdroRawData;
floatTempData;
floatVccPintData;
floatVccPauxData;
floatMaxData;
floatMinData;
XAdcPs *XAdcInstPtr = &XAdcInst;
printf(" Entering the XAdc PolledExample. ");
/*
* Initialize the XAdc driver.
*/
ConfigPtr= XAdcPs_LookupConfig(XAdcDeviceId);
if(ConfigPtr == NULL) {
returnXST_FAILURE;
}
XAdcPs_CfgInitialize(XAdcInstPtr,ConfigPtr,
ConfigPtr->BaseAddress);
/*
* Self Test the XADC/ADC device
*/
Status= XAdcPs_SelfTest(XAdcInstPtr);
if(Status != XST_SUCCESS) {
returnXST_FAILURE;
}
/*
* Disable the Channel Sequencer beforeconfiguring the Sequence
* registers.
*/
XAdcPs_SetSequencerMode(XAdcInstPtr,XADCPS_SEQ_MODE_SAFE);
/*
* Read the on-chip Temperature Data(Current/Maximum/Minimum)
* from the ADC data registers.
*/
TempRawData= XAdcPs_GetAdcData(XAdcInstPtr, XADCPS_CH_TEMP);
TempData= XAdcPs_RawToTemperature(TempRawData);
printf(" The Current Temperature is%0d.%03d Centigrades. ",
(int)(TempData), XAdcFractionToInt(TempData));
TempRawData= XAdcPs_GetMinMaxMeasurement(XAdcInstPtr, XADCPS_MAX_TEMP);
MaxData= XAdcPs_RawToTemperature(TempRawData);
printf("The Maximum Temperature is%0d.%03d Centigrades. ",
(int)(MaxData), XAdcFractionToInt(MaxData));
TempRawData= XAdcPs_GetMinMaxMeasurement(XAdcInstPtr, XADCPS_MIN_TEMP);
MinData= XAdcPs_RawToTemperature(TempRawData & 0xFFF0);
printf("The Minimum Temperature is%0d.%03d Centigrades. ",
(int)(MinData), XAdcFractionToInt(MinData));
/*
* Read the VccPint Votage Data(Current/Maximum/Minimum) from the
* ADC data registers.
*/
VccPintRawData= XAdcPs_GetAdcData(XAdcInstPtr, XADCPS_CH_VCCPINT);
VccPintData= XAdcPs_RawToVoltage(VccPintRawData);
printf(" The Current VCCPINT is%0d.%03d Volts. ",
(int)(VccPintData),XAdcFractionToInt(VccPintData));
VccPintRawData= XAdcPs_GetMinMaxMeasurement(XAdcInstPtr,
XADCPS_MAX_VCCPINT);
MaxData= XAdcPs_RawToVoltage(VccPintRawData);
printf("The Maximum VCCPINT is %0d.%03dVolts. ",
(int)(MaxData), XAdcFractionToInt(MaxData));
VccPintRawData= XAdcPs_GetMinMaxMeasurement(XAdcInstPtr,
XADCPS_MIN_VCCPINT);
MinData= XAdcPs_RawToVoltage(VccPintRawData);
printf("The Minimum VCCPINT is %0d.%03dVolts. ",
(int)(MinData), XAdcFractionToInt(MinData));
/*
* Read the VccPaux Votage Data(Current/Maximum/Minimum) from the
* ADC data registers.
*/
VccPauxRawData= XAdcPs_GetAdcData(XAdcInstPtr, XADCPS_CH_VCCPAUX);
VccPauxData= XAdcPs_RawToVoltage(VccPauxRawData);
printf(" The Current VCCPAUX is%0d.%03d Volts. ",
(int)(VccPauxData),XAdcFractionToInt(VccPauxData));
VccPauxRawData= XAdcPs_GetMinMaxMeasurement(XAdcInstPtr,
XADCPS_MAX_VCCPAUX);
MaxData= XAdcPs_RawToVoltage(VccPauxRawData);
printf("The Maximum VCCPAUX is %0d.%03dVolts. ",
(int)(MaxData), XAdcFractionToInt(MaxData));
VccPauxRawData= XAdcPs_GetMinMaxMeasurement(XAdcInstPtr,
XADCPS_MIN_VCCPAUX);
MinData= XAdcPs_RawToVoltage(VccPauxRawData);
printf("The Minimum VCCPAUX is %0d.%03dVolts. ",
(int)(MinData), XAdcFractionToInt(MinData));
/*
* Read the VccPdro Votage Data(Current/Maximum/Minimum) from the
* ADC data registers.
*/
VccPdroRawData= XAdcPs_GetAdcData(XAdcInstPtr, XADCPS_CH_VCCPDRO);
VccPintData= XAdcPs_RawToVoltage(VccPdroRawData);
printf(" The Current VCCPDDRO is%0d.%03d Volts. ",
(int)(VccPintData), XAdcFractionToInt(VccPintData));
VccPdroRawData= XAdcPs_GetMinMaxMeasurement(XAdcInstPtr,
XADCPS_MAX_VCCPDRO);
MaxData= XAdcPs_RawToVoltage(VccPdroRawData);
printf("The Maximum VCCPDDRO is %0d.%03dVolts. ",
(int)(MaxData), XAdcFractionToInt(MaxData));
VccPdroRawData= XAdcPs_GetMinMaxMeasurement(XAdcInstPtr,
XADCPS_MIN_VCCPDRO);
MinData= XAdcPs_RawToVoltage(VccPdroRawData);
printf("The Minimum VCCPDDRO is %0d.%03dVolts. ",
(int)(MinData), XAdcFractionToInt(MinData));
printf("Exiting the XAdc Polled Example. ");
returnXST_SUCCESS;
}
/****************************************************************************/
/**
*
* This function converts the fractionpart of the given floating point number
* (after the decimal point)to aninteger.
*
* @param FloatNum is the floating point number.
*
* @return Integer number to a precision of 3 digits.
*
* @note
* This function is used in the printingof floating point data to a STDIO device
* using the xil_printf function. Thexil_printf is a very small foot-print
* printf function and does notsupport the printing of floating point numbers.
*
*****************************************************************************/
intXAdcFractionToInt(floatFloatNum)
{
floatTemp;
Temp= FloatNum;
if(FloatNum < 0) {
Temp= -(FloatNum);
}
return( ((int)((Temp -(float)((int)Temp)) * (1000.0f))));
}
原文標題:Zynq中PS端XADC
文章出處:【微信公眾號:FPGA之家】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。
責任編輯:haq
-
cpu
+關(guān)注
關(guān)注
68文章
10854瀏覽量
211578 -
Zynq
+關(guān)注
關(guān)注
10文章
609瀏覽量
47175
原文標題:Zynq中PS端XADC
文章出處:【微信號:zhuyandz,微信公眾號:FPGA之家】歡迎添加關(guān)注!文章轉(zhuǎn)載請注明出處。
發(fā)布評論請先 登錄
相關(guān)推薦
評論