ADC_MEASUREMENT: Methods

ADC MEASUREMENT

ADC_MEASUREMENT
Methods
DAVE_APP_VERSION_t ADC_MEASUREMENT_GetAppVersion (void)
 Get ADC_MEASUREMENT APP version.
ADC_MEASUREMENT_STATUS_t ADC_MEASUREMENT_Init (ADC_MEASUREMENT_t *const handle_ptr)
 Initializes the APP to measure a set of analog inputs.

void ADC_MEASUREMENT_StartConversion (ADC_MEASUREMENT_t *const handle_ptr)
 Starts the conversion of the required measurements.

XMC_VADC_RESULT_SIZE_t ADC_MEASUREMENT_GetResult (ADC_MEASUREMENT_CHANNEL_t *const handle_ptr)
 Returns the converted value for a specific channel. Not Applicable for XMC1100.

uint32_t ADC_MEASUREMENT_GetDetailedResult (ADC_MEASUREMENT_CHANNEL_t *const handle_ptr)
 Returns a detailed conversion result. Not Applicable for XMC1100.

XMC_VADC_RESULT_SIZE_t ADC_MEASUREMENT_GetResult (ADC_MEASUREMENT_t *const handle_ptr) ADC_MEASUREMENT_DEPRECATED
 Returns the converted value from the global result register. Only Applicable for XMC1100.

uint32_t ADC_MEASUREMENT_GetDetailedResult (ADC_MEASUREMENT_t *const handle_ptr) ADC_MEASUREMENT_DEPRECATED
 Returns a detailed conversion result. Only Applicable for XMC1100.

__STATIC_INLINE
XMC_VADC_RESULT_SIZE_t 
ADC_MEASUREMENT_GetGlobalResult (void)
 Returns the converted value from the global result register. Only Applicable for XMC1100.

__STATIC_INLINE uint32_t ADC_MEASUREMENT_GetGlobalDetailedResult (void)
 Returns a detailed conversion result. Only Applicable for XMC1100.

Methods


Function Documentation

DAVE_APP_VERSION_t ADC_MEASUREMENT_GetAppVersion ( void  )

Get ADC_MEASUREMENT APP version.

Returns:
DAVE_APP_VERSION_t APP version information (major, minor and patch number)
Description:
The function can be used to check application software compatibility with a specific version of the APP.

Example Usage:

 #include <DAVE.h>

 int main(void) {
   DAVE_STATUS_t init_status;
   DAVE_APP_VERSION_t version;

   // Initialize ADC_MEASUREMENT APP:
   // ADC_MEASUREMENT_Init() is called from within DAVE_Init().
   init_status = DAVE_Init();

   version = ADC_MEASUREMENT_GetAppVersion();
   if (version.major != 1U) {
     // Probably, not the right version.
   }

   // More code here
   while(1) {

   }
   return (0);
 }

Definition at line 111 of file ADC_MEASUREMENT.c.

Returns a detailed conversion result. Not Applicable for XMC1100.

Parameters:
handle_ptrconstant pointer to the channel handle structure. (Use the channel handle related macros which are defined in adc_measurement_conf.h)
Returns:
uint32_t The complete result register.
Description:
Returns the 32 bit result register (GxRES[y]) completely. The result of conversion as well as other informations are returned from this API. The detailed result register contains result of the most recent conversion, the channel number requested the conversion, valid flag, converted request source and fast compare result. In polling mechanism the converted result can be read out after checking the valid flag bit. This API can be used in applications where, the channel number associated to the result register is also needed for verification.
Note:
This API is not Applicable for XMC1100 microcontroller, because all the channels shares a common result register called GLOBRES. Use ADC_MEASUREMENT_GetDetailedResult(ADC_MEASUREMENT_t *const handle_ptr) for XMC1100 microcontrollers.
  #include <DAVE.h>

  typedef struct detailed_result_struct
  {
        uint8_t channel_num;
        uint8_t group_num;
        uint16_t conversion_result;
  }detailed_result_struct_t;

  uint32_t result;
  bool valid_result;
  detailed_result_struct_t detailed_result;

  void Adc_Measurement_Handler()
  {
        uint32_t result;
    valid_result = (bool)false;
  #if(UC_SERIES != XMC11)
    result = ADC_MEASUREMENT_GetDetailedResult(&ADC_MEASUREMENT_Channel_A);
    if((bool)(result >> VADC_G_RES_VF_Pos))
    {
       valid_result = (bool)true;
       detailed_result.channel_num = (result & VADC_G_RES_CHNR_Msk) >> VADC_G_RES_CHNR_Pos;
       detailed_result.group_num = ADC_MEASUREMENT_Channel_A.group_index;
       detailed_result.conversion_result = result & VADC_G_RES_RESULT_Msk;
    }
  #endif
  }

  int main(void)
  {
     DAVE_Init();
     ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);
     while(1);
     return 0;
  }

Definition at line 250 of file ADC_MEASUREMENT.c.

References ADC_MEASUREMENT_CHANNEL::ch_handle, and ADC_MEASUREMENT_CHANNEL::group_handle.

uint32_t ADC_MEASUREMENT_GetDetailedResult ( ADC_MEASUREMENT_t *const  handle_ptr)

Returns a detailed conversion result. Only Applicable for XMC1100.

Parameters:
handle_ptrconstant pointer to the APP handle structure.
Returns:
uint32_t The complete Result register.
Description:
Returns the 32 bit result register (GLOBRES) completely. The result of conversion as well as other informations are returned from this API. The detailed result register contains result of the most recent conversion, the channel number requested the conversion, valid flag, converted request source and fast compare result. In polling mechanism the converted result can be read out after checking the valid flag bit. This API can be used in applications where, the channel number associated to the result register is also needed for verification. This API is only used in the microcotrollers where group result registers are not available. Hence for these microntroller devices, all the conversion results are stored in the global result register in shared mode. The wait for read mode hardware option will be enabled for the global result register to avoid overwriting of results. To get a new channel conversion result, it is mandatory to read the previous result using the same API or ADC_MEASUREMENT_GetResult API.
Note:
  • This API is applicable only for XMC1100 microcontroller, because all the channels shares a common result register called GLOBRES. Use ADC_MEASUREMENT_GetDetailedResult(ADC_MEASUREMENT_CHANNEL_t *const handle_ptr) for other microcontrollers.
  • For either 10Bit or 8Bit ADC resolution the result value needs to be right shifted by either 2 or 4 bits respectively. The 10Bit or 8 bit results are left aligned in the result register, hence a shift operation is needed.
  #include <DAVE.h>

  typedef struct detailed_result_struct
  {
        uint8_t channel_num;
        uint8_t group_num;
        uint16_t conversion_result;
  }detailed_result_struct_t;

  uint32_t result;
  bool valid_result;
  detailed_result_struct_t detailed_result[10];

  void Adc_Measurement_Handler()
  {
        static uint8_t index;
        uint32_t result;
    valid_result = (bool)false;
  #if(UC_SERIES == XMC11)
    result = ADC_MEASUREMENT_GetDetailedResult(&ADC_MEASUREMENT_0);
  #endif

    if((bool)(result >> VADC_GLOBRES_VF_Pos))
    {
       valid_result = (bool)true;
       detailed_result[index].channel_num = (result & VADC_GLOBRES_CHNR_Msk) >> VADC_GLOBRES_CHNR_Pos;
       detailed_result[index].group_num = ADC_MEASUREMENT_Channel_A.group_index;
       detailed_result[index].conversion_result = (result & VADC_GLOBRES_RESULT_Msk) >>
                            ((uint32_t)ADC_MEASUREMENT_0.iclass_config_handle->conversion_mode_standard * (uint32_t)2);
    }
    index++;
  }

  int main(void)
  {
     DAVE_Init();
     ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);
     while(1);
     return 0;
  }

Definition at line 283 of file ADC_MEASUREMENT.c.

References ADC_MEASUREMENT_GetGlobalDetailedResult().

__STATIC_INLINE uint32_t ADC_MEASUREMENT_GetGlobalDetailedResult ( void  )

Returns a detailed conversion result. Only Applicable for XMC1100.

Parameters:
handle_ptrconstant pointer to the APP handle structure.
Returns:
uint32_t The complete Result register.
Description:
Returns the 32 bit result register (GLOBRES) completely. The result of conversion as well as other informations are returned from this API. The detailed result register contains result of the most recent conversion, the channel number requested the conversion, valid flag, converted request source and fast compare result. In polling mechanism the converted result can be read out after checking the valid flag bit. This API can be used in applications where, the channel number associated to the result register is also needed for verification. This API is only used in the microcotrollers where group result registers are not available. Hence for these microntroller devices, all the conversion results are stored in the global result register in shared mode. The wait for read mode hardware option will be enabled for the global result register to avoid overwriting of results. To get a new channel conversion result, it is mandatory to read the previous result using the same API or ADC_MEASUREMENT_GetResult API.
Note:
  • This API is applicable only for XMC1100 microcontroller, because all the channels shares a common result register called GLOBRES. Use ADC_MEASUREMENT_GetDetailedResult(ADC_MEASUREMENT_CHANNEL_t *const handle_ptr) for other microcontrollers.
  • For either 10Bit or 8Bit ADC resolution the result value needs to be right shifted by either 2 or 4 bits respectively. The 10Bit or 8 bit results are left aligned in the result register, hence a shift operation is needed.
  #include <DAVE.h>

  typedef struct detailed_result_struct
  {
        uint8_t channel_num;
        uint8_t group_num;
        uint16_t conversion_result;
  }detailed_result_struct_t;

  uint32_t result;
  bool valid_result;
  detailed_result_struct_t detailed_result[10];

  void Adc_Measurement_Handler()
  {
        static uint8_t index;
        uint32_t result;
    valid_result = (bool)false;
  #if(UC_SERIES == XMC11)
    result = ADC_MEASUREMENT_GetGlobalDetailedResult();
  #endif

    if((bool)(result >> VADC_GLOBRES_VF_Pos))
    {
       valid_result = (bool)true;
       detailed_result[index].channel_num = (result & VADC_GLOBRES_CHNR_Msk) >> VADC_GLOBRES_CHNR_Pos;
       detailed_result[index].group_num = ADC_MEASUREMENT_Channel_A.group_index;
       detailed_result[index].conversion_result = (result & VADC_GLOBRES_RESULT_Msk) >>
                            ((uint32_t)ADC_MEASUREMENT_0.iclass_config_handle->conversion_mode_standard * (uint32_t)2);
    }
    index++;
  }

  int main(void)
  {
     DAVE_Init();
     ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);
     while(1);
     return 0;
  }

Definition at line 695 of file ADC_MEASUREMENT.h.

Referenced by ADC_MEASUREMENT_GetDetailedResult().

__STATIC_INLINE XMC_VADC_RESULT_SIZE_t ADC_MEASUREMENT_GetGlobalResult ( void  )

Returns the converted value from the global result register. Only Applicable for XMC1100.

Parameters:
handle_ptrconstant pointer to the APP handle structure.
Returns:
XMC_VADC_RESULT_SIZE_t conversion result.
Range: [ 0x0 to 0x3FF] if accumulation of results is switched off.
Description:
Reads the converted result stored in the common result register [GLOBRES], assigned to all the channels. This API is only used in the microcotrollers where group result registers are not available. Hence for these microntroller devices, all the conversion results are stored in the global result register in shared mode. The wait for read mode hardware option will be enabled for the global result register to avoid overwriting of results. To get a new channel conversion result, it is mandatory to read the previous result using the same API or ADC_MEASUREMENT_GetGlobalDetailedResult API.
Note:
  • This API is only applicable for XMC1100 microcontroller, because all the channels shares a common result register called GLOBRES. Hence this API shall be called with a pointer to the measurement handle of type ADC_MEASUREMENT_t.
  • For either 10Bit or 8Bit ADC resolution the result value needs to be right shifted by either 2 or 4 bits respectively. The 10Bit or 8 bit results are left aligned in the result register, hence a shift operation is needed.
  // Ensure that end of measurements interrupt has been enabled
  #include <DAVE.h>

  XMC_VADC_RESULT_SIZE_t result;
  void Adc_Measurement_Handler()
  {
  #if(UC_SERIES == XMC11)
   result = ADC_MEASUREMENT_GetGlobalResult();
  #endif
   result = result >> ((uint32_t)ADC_MEASUREMENT_0.iclass_config_handle->conversion_mode_standard * (uint32_t)2);
  }

  int main(void)
  {
     DAVE_Init();
     ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);
     while(1);
     return 0;
  }

Definition at line 614 of file ADC_MEASUREMENT.h.

Referenced by ADC_MEASUREMENT_GetResult().

XMC_VADC_RESULT_SIZE_t ADC_MEASUREMENT_GetResult ( ADC_MEASUREMENT_CHANNEL_t *const  handle_ptr)

Returns the converted value for a specific channel. Not Applicable for XMC1100.

Parameters:
handle_ptrConstant pointer to the channel handle structure of type ADC_MEASUREMENT_CHANNEL_t. (Use the channel handle related macros which are defined in adc_measurement_conf.h)
Returns:
XMC_VADC_RESULT_SIZE_t conversion result.
Range: [ 0x0 to 0x3FF] if accumulation of results is switched off.
Description:
Reads the converted result stored in the result register [GxRESy.RESULT], assigned to the specified channel. This API is only used in the microcotrollers where separate result registers are available for storing each channel results. For these microcontrollers, each channel is configured to a particular group result register. The result register is defined in the channel handle structure ADC_MEASUREMENT_CHANNEL_t. Hence this API shall call be called with a pointer to the channel handle of type ADC_MEASUREMENT_CHANNEL_t (Directly use the channel handle related macros which are defined in adc_measurement_conf.h).
Note:
This API is not Applicable for XMC1100 microcontroller, because all the channels shares a common result register called GLOBRES. Use ADC_MEASUREMENT_GetResult(ADC_MEASUREMENT_t *const handle_ptr) for XMC1100 microcontrollers.
  // Ensure that end of measurements interrupt has been enabled
  #include <DAVE.h>

  XMC_VADC_RESULT_SIZE_t result;
  void Adc_Measurement_Handler()
  {
  #if(UC_SERIES != XMC11)
    result = ADC_MEASUREMENT_GetResult(&ADC_MEASUREMENT_Channel_A);
  #endif
  }

  int main(void)
  {
     DAVE_Init();
     ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);
     while(1);
     return 0;
  }

Definition at line 237 of file ADC_MEASUREMENT.c.

References ADC_MEASUREMENT_CHANNEL::ch_handle, and ADC_MEASUREMENT_CHANNEL::group_handle.

XMC_VADC_RESULT_SIZE_t ADC_MEASUREMENT_GetResult ( ADC_MEASUREMENT_t *const  handle_ptr)

Returns the converted value from the global result register. Only Applicable for XMC1100.

Parameters:
handle_ptrconstant pointer to the APP handle structure.
Returns:
XMC_VADC_RESULT_SIZE_t conversion result.
Range: [ 0x0 to 0x3FF] if accumulation of results is switched off.
Description:
Reads the converted result stored in the common result register [GLOBRES], assigned to all the channels. This API is only used in the microcotrollers where group result registers are not available. Hence for these microntroller devices, all the conversion results are stored in the global result register in shared mode. The wait for read mode hardware option will be enabled for the global result register to avoid overwriting of results. To get a new channel conversion result, it is mandatory to read the previous result using the same API or ADC_MEASUREMENT_GetDetailedResult API.
Note:
  • This API is only applicable for XMC1100 microcontroller, because all the channels shares a common result register called GLOBRES. Hence this API shall be called with a pointer to the measurement handle of type ADC_MEASUREMENT_t.
  • For either 10Bit or 8Bit ADC resolution the result value needs to be right shifted by either 2 or 4 bits respectively. The 10Bit or 8 bit results are left aligned in the result register, hence a shift operation is needed.
  // Ensure that end of measurements interrupt has been enabled
  #include <DAVE.h>

  XMC_VADC_RESULT_SIZE_t result;
  void Adc_Measurement_Handler()
  {
  #if(UC_SERIES == XMC11)
   result = ADC_MEASUREMENT_GetResult(&ADC_MEASUREMENT_0);
  #endif
   result = result >> ((uint32_t)ADC_MEASUREMENT_0.iclass_config_handle->conversion_mode_standard * (uint32_t)2);
  }

  int main(void)
  {
     DAVE_Init();
     ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);
     while(1);
     return 0;
  }

Definition at line 266 of file ADC_MEASUREMENT.c.

References ADC_MEASUREMENT_GetGlobalResult().

Initializes the APP to measure a set of analog inputs.

Parameters:
handle_ptrconstant pointer to the APP handle structure
Returns:
ADC_MEASUREMENT_STATUS_SUCCESS when initialization succeeds else, return ADC_MEASUREMENT_STATUS_FAILURE.
Description:
Initializes the VADC background scan request source, group channels and result registers with the configuration specified in the handle structure. The API configures the conversion timing parameters of VADC, by setting the [GLOBICLASS] register. The API initializes the channel and result configurations by setting the [GxCHCTRy] and [GxRCRy] registers respectively. It adds all channels into the background request source channel select register [BRSSEL]. For microcontrollers apart from XMC1100, the APP uses background request source event to generate the interrupt. For XMC1100 devices, global result event is used to generate the interrupt. If "Start conversion after initialization" has been selected in the GUI, the ADC conversions starts immediately at the end of this API call.
 #include <DAVE.h>
 int main(void)
 {
    DAVE_Init(); //ADC_MEASUREMENT_Init is called within DAVE_Init
    return 0;
 }

Definition at line 124 of file ADC_MEASUREMENT.c.

References ADC_MEASUREMENT_STATUS_UNINITIALIZED, ADC_MEASUREMENT_CHANNEL::analog_io_config, ADC_MEASUREMENT::array, ADC_MEASUREMENT::backgnd_config_handle, ADC_MEASUREMENT_CHANNEL::ch_handle, ADC_MEASUREMENT_CHANNEL::ch_num, ADC_MEASUREMENT_CHANNEL_ARRAY::channel_array, ADC_MEASUREMENT::global_handle, ADC_MEASUREMENT_CHANNEL::group_handle, ADC_MEASUREMENT_CHANNEL::group_index, ADC_MEASUREMENT::iclass_config_handle, ADC_MEASUREMENT::init_state, ADC_MEASUREMENT_ISR::irqctrl, ADC_MEASUREMENT::mux_config, ADC_MEASUREMENT_ISR::node_id, ADC_MEASUREMENT_ISR::priority, ADC_MEASUREMENT::req_src_intr_handle, ADC_MEASUREMENT_CHANNEL::res_handle, ADC_MEASUREMENT_CHANNEL_ARRAY::res_handle, ADC_MEASUREMENT::result_intr_handle, ADC_MEASUREMENT::srv_req_node, ADC_MEASUREMENT::start_conversion, and ADC_MEASUREMENT_ISR::sub_priority.

Starts the conversion of the required measurements.

Parameters:
handle_ptrConstant pointer to the APP handle structure
Returns:
None
Description:
If "Start conversion after initialization" option is not selected in the GUI, the conversions can be started by calling this API. A call to this API sets the register bit field BRSMR.LDEV to generate a load event. The load event triggers the conversion of selected channels in a fixed sequence. A conversion request can also be raised upon detection of a hardware trigger. Hence, if "Start conversion after initialization" option enabled or "Trigger edge Selection" is configured to any edge, this API call is not mandatory to start the conversions.
  // Ensure that end of measurements interrupt has been enabled
  #include <DAVE.h>

  XMC_VADC_RESULT_SIZE_t result;
  void Adc_Measurement_Handler()
  {
  #if(UC_SERIES != XMC11)
    result = ADC_MEASUREMENT_GetResult(&ADC_MEASUREMENT_Channel_A);
  #else
    result = ADC_MEASUREMENT_GetGlobalResult();
  #endif
  }

  int main(void)
  {
     DAVE_Init();
     ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);
     while(1);
     return 0;
  }

Definition at line 227 of file ADC_MEASUREMENT.c.

References ADC_MEASUREMENT::global_handle.