XMC1100 Reading 2 ADC's

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

cross mob
User13817
Level 3
Level 3
Hello,

I configured the Dave APP to make two ADC measurements (P2.7 and P2.9) and I'm not having success reading the values. I can read one value but I don't know how can I read the other one because it uses a global register to store the values.
I'm using DAVE 4 with a Sense 2 Go Kit (XMC1100).

Following is my code:

// Global variables
XMC_VADC_RESULT_SIZE_t adc1Raw;
XMC_VADC_RESULT_SIZE_t adc2Raw;

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

}
}

// Interrupt
void Adc_Measurement_Handler()
{
adc1Raw = ADC_MEASUREMENT_GetGlobalResult() & 0xFFF;
adc2Raw = ???
}

2861.attach

2862.attach
0 Likes
3 Replies
Andi_H
Employee
Employee
First solution authored First like received
Hello persike,

-enable continuouse conversion to get more then one meassurement (or call the api ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0 ) after each measuerement again...)
-change your result variables to an array like adcRaw[2] ...

-then make a for loop and get the results after each other (with the ADC_MEASUREMENT_GetGlobalResult())

or:
adcRaw[0]=ADC_MEASUREMENT_GetGlobalResult():
adcRaw[1]=ADC_MEASUREMENT_GetGlobalResult():

... and so on.

the right order is a little bit tricky (which channel is what)

it is desrcibe in the application manuel... i dont have access at the moment to this...

look also at:

https://www.infineonforums.com/threads/4563-XMC-1100-ADC-how-to-add-a-second-channel

best regards

andi
0 Likes
User22557
Level 1
Level 1
Hello,
I am having the same problem and i saw your explanation and tried to make it like you described. The pins are reading values but not the rigth way(always oscillating between 0 and the value, and when i connect all the pins to 3.3v they stop oscillating and the value is stable in 4095[12 bits adc] ).
Can you please give me an example code for 2 ADC channels? (I am using the XMC1100 2GO).
Also, can you show the adc configurations?

Best regards,
Tiago Rocha
0 Likes
ArmandoPinedaM
Level 1
Level 1
First like given First reply posted First question asked

Hi!
I'm new to Infineon uC's but i think i have the solution here.

I've been testing the ADC on my XMC2Go 1100 and fount that this u'C doesnt have a vector to save each vonvertion, so you have to check if the result is for one port or the other.

To do this you can use the ADC_MEASUREMENT_GetGlobalDetailedResult() function which returns the measurment and other information on the same uint32_t variable.

So my code look like this:

uint16_t ADC_result[2];    //Vector to store the results

void Adc_Measurement_Handler(void)
{
    uint32_t result;    //Var to store the result
    result = ADC_MEASUREMENT_GetGlobalDetailedResult();    //Getting the result

    //If the chanel is eq to Channel_A it stores it on first place
    if( ADC_MEASUREMENT_Channel_A_handle.ch_num == (result & VADC_GLOBRES_CHNR_Msk) >> VADC_GLOBRES_CHNR_Pos )
    {
        ADC_result[0] = (result & VADC_GLOBRES_RESULT_Msk) >> ((uint32_t)ADC_MEASUREMENT_0.iclass_config_handle->conversion_mode_standard * (uint32_t)2);
    }
    //If the chanel is eq to Channel_B it stores it on second place
    if( ADC_MEASUREMENT_Channel_B_handle.ch_num == (result & VADC_GLOBRES_CHNR_Msk) >> VADC_GLOBRES_CHNR_Pos )
    {
        ADC_result[1] = (result & VADC_GLOBRES_RESULT_Msk) >> ((uint32_t)ADC_MEASUREMENT_0.iclass_config_handle->conversion_mode_standard * (uint32_t)2);
    //Triggers another convertion
    ADC_MEASUREMENT_StartConversion(&ADC_MEASUREMENT_0);
    }
}

Also my ADC DAVE appconfiguration is the next:

ArmandoPinedaM_0-1658869079214.png

ArmandoPinedaM_1-1658869102329.png

 

ArmandoPinedaM_2-1658869118932.png

 

Hope it solves your problem.

 

0 Likes