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

XMC™ Forum Discussions

User17585
Level 1
Level 1
Hi,

in my project using an XMC1100 with DAVE Apps I trigger ADC_MEASUREMENT by an PWM_CCU4
on Period match as well as Compare match while counting up.
An interrupt handler for ADC_MEASUREMENT then evaluates the results.

Since I switch a power MOSFET with the PWM output signal my measurements have rather different meanings
whether PWM is in active vs. inactive phase. How can I determine in which phase the PWM_CCU4 is currently?

PWM frequency is low (sub 1kHz). Thus PWM state will not have changed from the one it had during the ADC
did its measurements.

By the way, PWM_CCU4 will not signal Compare match while counting up when Duty Cycle is set to 0.0%, right?

Markus
0 Likes
2 Replies
jferreira
Employee
Employee
First like received 750 replies posted 500 replies posted
Hi,

You could use the GCST register.

Regards,
Jesus
0 Likes
User17585
Level 1
Level 1
Thanks! That did the job. If you have the same problem here is my code snippet (you need to include XMC1100.h for that which is automatically done by including DAVE.h):

#include

...

// Register GCST contains the information whether the CCU4 is in its active or
// inactive phase (its state thus ST).
// The slice number of the CCU4 slice (0-3) used can be found out using the
// resource report (button in DAVE).
if ((CCU40->GCST & CCU4_GCST_CC41ST_Msk) == CCU4_GCST_CC41ST_Msk) {
...
}

Triggering the ADC conversion from the PWM CCU4 works fine for me as long as I trigger only on "Compare match while counting up". Since I want to trigger on start as well as the end of the active PWM cycle I tried this:

3692.attach
3693.attach

Now the ADC conversion will not trigger any more at all.

I had to introduce an additional Interrupt App which is triggered on the CCU4 "Period match". In the IRQ handler routine the ADC conversion is then started. Not a beautiful workaround.

Markus
0 Likes