XMC 1100 ADC how to add a second channel

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

cross mob
Not applicable
Hi,

i get the result of Channel_A, my problem is that i don't know how to add a second Channel to my Code.

I use DAVE 4 and a XMC 1100 Bootkit.

/*
* main.c
*
* Created on: 2016 May 25 11:10:44
* Author: Dominik
*/

#include //Declarations from DAVE Code Generation (includes SFR declaration)
XMC_VADC_RESULT_SIZE_t result_a;
void Adc_Measurement_Handler()
{
result_a = ADC_MEASUREMENT_GetResult(&ADC_MEASUREMENT_0);
}

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)
{

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

}
}

I hope you can help me.

Big Thank, Dominik!
0 Likes
4 Replies
Not applicable
Hi,

maybe it help when i define my problem a litte bit more.

I would to read in 2 or 3 Poti, with the code above i could read only 1 Poti.

Yesterday i tried the hole day to read a second poti but all my attempts failed.

Poti one is on port 2.2 and the second one at 2.3.

I hope you can help me know a litte bit easyier.
0 Likes
Andi_H
Employee
Employee
First solution authored First like received
Hey Dominik,

did you change the "number of measurements" to 2 or 3...?

The next step is, that you have to know:

you have only "1"result register. So you have to read one by one...

You can read more than one result for example with this code:

void Adc_Measurement_Handler()
{
static uint8_t n=0;

if(n==2)
{
n=0;
}

result= ADC_MEASUREMENT_GetResult(&ADC_MEASUREMENT_0); //liest jeweiligen Werte (nach jeder Messung steht nächster Wert bereit)
n++;
}

2370.attach
0 Likes
Not applicable
Hi Andy

Danke für die Hilfe und den Tipp mit dem nur einen Register!

ich habe das jetzt mal so umgesetzt:


XMC_VADC_RESULT_SIZE_t result[2];

void Adc_Measurement_Handler()
{
static uint8_t n=0;

if(n==2)
{
n=0;
}

result= ADC_MEASUREMENT_GetResult(&ADC_MEASUREMENT_0); //liest jeweiligen Werte (nach jeder Messung steht nächster Wert bereit)
n++;
}

doch leider bekomme ich keinen input beide results zeigen den gleichen 4000er wert an...

eine Idee.

If it is not ok to write here in German please let me know than i will do this!
0 Likes
Andi_H
Employee
Employee
First solution authored First like received
Hey Dominik,

here is an example for you from me...

https://www.dropbox.com/s/gs3qpv61j3pip2p/ADC_XMC1100_EXAMPLE.zip?dl=0

You need DAVE 4.3.2 ( Dont know it works with older versions....)

Import Project, compile it and debug... and look in the app configuration to understand.


Analog Input Pin 2.6+2.8


Grüße
0 Likes