ADC with 2 channels (XMC1100)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Dom
Employee
Employee
How to read 2 Channels by ADC at XMC1100 BootKit.

We ran into the problem how to use the (one)ADC with 2 (or more)channels.
If you select "Interrupt after each measurement" in the ADC App,
the ADC result will be overwritten by the result of the 2.(or next) ADC-Channel.
, see picture






An easy way of reading each ADC result is to use a counter variable to destinguish between the 2 ADC channels results in an if-statement
******** result = ADC_MEASUREMENT_GetResult(&ADC_MEASUREMENT_0);
******** count++;
#endif

******** if(count==1 && result >= 2048)
******** {
************ DIGITAL_IO_SetOutputLow(&LED0);
******** }
******** else
******** {
************ DIGITAL_IO_SetOutputHigh(&LED0);
******** }


******** if(count==2 && result* >= 2048)
******** {
************ DIGITAL_IO_SetOutputLow(&LED1);
******** }
******* *else
******** {
************ DIGITAL_IO_SetOutputHigh(&LED1);
******** }
}



int main(void)
{
* DAVE_STATUS_t status;

* status = DAVE_Init();********** /* Initialization of DAVE APPs* */

* if(status == DAVE_STATUS_FAILURE)
* {
*** /* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
*** XMC_DEBUG("DAVE APPs initialization failed\n");

*** while(1U)
*** {

*** }
* }

* /* Placeholder for user application code. The while loop below can be replaced with user application code. */
* DIGITAL_IO_SetOutputHigh(&LED0);
* DIGITAL_IO_SetOutputHigh(&LED1);
* while(1U)
* {
***** count=0;
*************** * ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);
* }
}


You need to reset the counter to 0 before the next ADC_Measurement Convertion.
0 Likes
1 Reply
lock attach
Attachments are accessible only for community members.
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Hi,

You can make use of the Wait for Read mode which only start the next conversion until the result registers is being read. Attached is the VADC example using queue source.


const XMC_VADC_RESULT_CONFIG_t g_result_handle [VADC_RES_MAX] =
{
// Result register 0
{
.post_processing_mode = XMC_VADC_DMM_REDUCTION_MODE,
.data_reduction_control = 0,
.part_of_fifo = false, /* No FIFO */
.wait_for_read_mode = true, /* WFS */
.event_gen_enable = false /* No result event */
},



1626.attach
0 Likes