xadcps
Vitis Drivers API Documentation
xadcps_intr_example.c File Reference

Overview

This file contains a design example using the driver functions of the XADC/ADC driver.

This example here shows the usage of the driver/device in interrupt mode to handle on-chip temperature and voltage alarm interrupts.

Note

This code assumes that no Operating System is being used.

The values of the on-chip temperature and the on-chip Vccaux voltage are read from the device and then the alarm thresholds are set in such a manner that the alarms occur.

MODIFICATION HISTORY:
Ver   Who    Date     Changes


1.00a bss 01/20/12 First release 2.2 ms 01/23/17 Modified xil_printf statement in main function to ensure that "Successfully ran" and "Failed" strings are available in all examples. This is a fix for CR-965028. 2.7 cog 07/24/23 Added support for SDT flow

Functions

int XAdcIntrExample (XScuGic *IntcInstancePtr, XAdcPs *XAdcInstPtr, u16 XAdcDeviceId, u16 XAdcIntrId, int *Temp)
 This function runs a test on the XADC/ADC device using the driver APIs. More...
 
int main (void)
 Main function that invokes the XADC Interrupt example. More...
 

Function Documentation

int main ( void  )

Main function that invokes the XADC Interrupt example.

Parameters
None.
Returns
  • XST_SUCCESS if the example has completed successfully.
  • XST_FAILURE if the example has failed.
Note
None.

References XAdcIntrExample().

int XAdcIntrExample ( XScuGic *  IntcInstancePtr,
XAdcPs XAdcInstPtr,
u16  XAdcDeviceId,
u16  XAdcIntrId,
int *  Temp 
)

This function runs a test on the XADC/ADC device using the driver APIs.

The function does the following tasks:

  • Initiate the XADC/ADC device driver instance
  • Run self-test on the device
  • Reset the device
  • Set up alarms for on-chip temperature and VCCPAUX
  • Set up sequence registers to continuously monitor on-chip temperature and VCCPAUX
  • Setup interrupt system
  • Enable interrupts
  • Set up configuration registers to start the sequence
  • Wait until temperature alarm interrupt or VCCPAUX alarm interrupt occurs
Parameters
IntcInstancePtris a pointer to the Interrupt Controller driver Instance.
XAdcInstPtris a pointer to the XAdcPs driver Instance.
XAdcDeviceIdis the XPAR_<SYSMON_ADC_instance>_DEVICE_ID value from xparameters.h.
XAdcIntrIdis XPAR_<INTC_instance>_<SYSMON_ADC_instance>_VEC_ID value from xparameters.h
Tempis an output parameter, it is a pointer through which the current temperature value is returned to the main function.
Returns
  • XST_SUCCESS if the example has completed successfully.
  • XST_FAILURE if the example has failed.
Note
This function may never return if no interrupt occurs.

References XAdcPs_Config::BaseAddress, XADCPS_ATR_TEMP_LOWER, XADCPS_ATR_TEMP_UPPER, XADCPS_ATR_VCCPAUX_LOWER, XADCPS_ATR_VCCPAUX_UPPER, XAdcPs_CfgInitialize(), XADCPS_CFR1_ALM_TEMP_MASK, XADCPS_CFR1_ALM_VCCPAUX_MASK, XADCPS_CH_TEMP, XADCPS_CH_VCCPAUX, XAdcPs_GetAdcData(), XAdcPs_IntrClear(), XAdcPs_IntrEnable(), XAdcPs_IntrGetStatus(), XADCPS_INTX_ALM0_MASK, XADCPS_INTX_ALM5_MASK, XAdcPs_LookupConfig(), XAdcPs_SelfTest(), XADCPS_SEQ_MODE_INDEPENDENT, XADCPS_SEQ_MODE_SAFE, XAdcPs_SetAlarmEnables(), XAdcPs_SetAlarmThreshold(), and XAdcPs_SetSequencerMode().

Referenced by main().