Nov 03, 2015
06:12 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 03, 2015
06:12 AM
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.
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.
1 Reply
Attachments are accessible only for community members.
Nov 03, 2015
06:26 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Nov 03, 2015
06:26 PM
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.
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 */
},