adc triggered through PWM rising edge

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

cross mob
User13827
Level 1
Level 1
First like received
Hi,

I'm trying to configure a simple programm, that starts the adc conversion with every pwm lrisng edge. I'm using the xmc1302 and DAVE Project. Can anybody guide me, how I have to set up the apps?

To generate the pwm I'm using CCU4, for the adc ADC_Measurement_ADV.

Question: do I need the event generator and event detector?

Thank you in advance.

Pablo
0 Likes
4 Replies
User13827
Level 1
Level 1
First like received
Hi,

nobody can tell me how does the synchronization work?

Thank you
0 Likes
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

Have a look at the DAVE4 examples, https://www.infineon.com/cms/en/product/promopages/aim-mc/dave_downloads.html. If you filter by ADC you will find examples matching exactly what you are trying to do.
BTW: You do not need the event routing (using ERU).

Regards,
Jesus
0 Likes
DRubeša
Employee
Employee
First solution authored First like received
Hi,

I had a quick look at your application use case so here is what I think it should work for you:

Under "16.17.3 Digital Module Connections in the XMC1300" chapter you can find following section:

3784.attach

You can see that you can connect trigger input by connecting CCU40.SR2/3 signal from CCU4 module. What are those signals from CCU4 module? Well you can find that the following figure in the CCU4 chapter to help you have better understanding of these signals.

3785.attach

So an interrupt event will generate these signals which can the be used to connect to trigger input of ADC module.

When we want to convert that in DAVE APPs settings:
3787.attach

3788.attach

3789.attach

I guess this should help you getting started with your application use case.

Best regards,
Deni
0 Likes
User13827
Level 1
Level 1
First like received
Hi everybody,

thank you for your answer. The synchronization worked yet but I'm experiencing some strange problems. I switch the pwm on and off. On in my main loop and off in my adc callback function. In debug mode everything works well but in release mode the pwn starts once and it doesn't work anymore.
Following you see the configuration of the pwm's and the start and stop commands.

Stopping pwm's in adc callback function:
void Adc_Measurement_ADV_Callback()
{

if(sig_cnt result_POTI= ADC_MEASUREMENT_ADV_GetResult(&ADC_MEASUREMENT_ADV_0_POTI_handle);//ADC_MEASUREMENT_GetResult(&ADC_MEASUREMENT_POTI_handle);
result_REF = ADC_MEASUREMENT_ADV_GetResult(&ADC_MEASUREMENT_ADV_0_REFERENCE_handle);
result_G1 = ADC_MEASUREMENT_ADV_GetResult(&ADC_MEASUREMENT_ADV_0_SIG_IN_G1_handle);
result_G2[sig_cnt] = ADC_MEASUREMENT_ADV_GetResult(&ADC_MEASUREMENT_ADV_0_SIG_IN_G2_handle);//

if(sig_cnt==SAMPLES-1){
PWM_CCU8_Stop(&PWM_CCU8_0_ADC_Trigger);
PWM_CCU8_Stop(&PWM_CCU8_0_LED_Output);
current_State = DATA_CONVERSION; //ADC_BUFFER_FULL;
sig_cnt = 0;
}
else{
current_State= ADC_UPDATE;
sig_cnt++;
}
}
}


Configuration from pwm's at start of the programm:
PWM_CCU8_Start(&PWM_CCU8_0_ADC_Trigger);
PWM_CCU8_Start(&PWM_CCU8_0_LED_Output);
status = PWM_CCU8_SetDutyCycleSymmetric(&PWM_CCU8_0_LED_Output, XMC_CCU8_SLICE_COMPARE_CHANNEL_1 ,5000);
status = PWM_CCU8_SetDutyCycleSymmetric(&PWM_CCU8_0_ADC_Trigger, XMC_CCU8_SLICE_COMPARE_CHANNEL_1 , 5000);

GLOBAL_CCU8_SyncStartTriggerHigh(GLOBAL_CCU8_CCUCON_Msk);


Restart from pwm's in main loop:
PWM_CCU8_Start(&PWM_CCU8_0_ADC_Trigger);
PWM_CCU8_Start(&PWM_CCU8_0_LED_Output);
GLOBAL_CCU8_SyncStartTriggerLow(GLOBAL_CCU8_CCUCON_Msk);
GLOBAL_CCU8_SyncStartTriggerHigh(GLOBAL_CCU8_CCUCON_Msk);


Can anybody tell me why the pwm's starts once in release mode?

Thank you in advance.

Pablo
0 Likes