PWM behaviout at high frequency

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

cross mob
Not applicable
Hi,
I am using the XMC4500 Relax Kit and I have created a PWM signal (using Dave, system frequency at 120 MHz, external frequency oscillator 12 MHz). I have also created two interruptions: Period Match Interrupt and Compare Match Interrupt that I have connected to the PWM signal. In the interrupt codes, I have only set then reset pins in order to visualize them thanks to an oscilloscope.
In the first place, I have set the PWM frequency to 100 kHz and I can see the good frequency for the PWM (yellow in pictures bellow) and pins corresponding to the interruption (green for the Period Match Interrupt and violet for the Compare Match Interrupt) are set then reset periodically and at the right moment.
Then I tried to configure the PWM frequency to 1MHz. It seems that the interrupts are not active at the right moment as the pins don’t toggle after every rising or falling edge. Besides, the period of each interruption is different whereas it shouldn’t have to. Is there a possibility to increase the PWM frequency a 1 MHz ?

945.attach944.attach

Best regards,
Jey
0 Likes
9 Replies
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Jey wrote:
Hi,
I am using the XMC4500 Relax Kit and I have created a PWM signal (using Dave, system frequency at 120 MHz, external frequency oscillator 12 MHz). I have also created two interruptions: Period Match Interrupt and Compare Match Interrupt that I have connected to the PWM signal. In the interrupt codes, I have only set then reset pins in order to visualize them thanks to an oscilloscope.
In the first place, I have set the PWM frequency to 100 kHz and I can see the good frequency for the PWM (yellow in pictures bellow) and pins corresponding to the interruption (green for the Period Match Interrupt and violet for the Compare Match Interrupt) are set then reset periodically and at the right moment.
Then I tried to configure the PWM frequency to 1MHz. It seems that the interrupts are not active at the right moment as the pins don’t toggle after every rising or falling edge. Besides, the period of each interruption is different whereas it shouldn’t have to. Is there a possibility to increase the PWM frequency a 1 MHz ?

945.attach944.attach

Best regards,
Jey


Hi Jey,

Is there any other interrupts other than the period and compare match interrupt within your software?

Best Regards
Travis
0 Likes
Not applicable
Hi Travis,
No, there is no other interrupt than the period and compare match interrupt (I am using the NVIC002 App for both interrupts).

Best regards,
Jey
0 Likes
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Hi Jey,

We are able to replicate this issue at PWM frequency of 500kHz by setting an IO during compare match and resetting the IO at period match. From the oscilloscope, we can see that the IO waveform is being delay which explains that the interrupt experience some delay of about 12 CLK cycles. This is very significant in high frequency as the compare/period match pulse width is very narrow. Therefore I can conclude that this is considered reasonable and would suggest that you reduce your PWM frequency
0 Likes
Not applicable
Hi Travis,
Thanks for your answer. I have an other question (maybe I have to create a new post?). Is there a solution to toggle an output at 10 Mhz ? I didn't succeed upper 4 MHz by setting and resetting a pin in a loop (without any interrupt or other fonction).

Best regards,
Jey
0 Likes
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Jey wrote:
Hi Travis,
Thanks for your answer. I have an other question (maybe I have to create a new post?). Is there a solution to toggle an output at 10 Mhz ? I didn't succeed upper 4 MHz by setting and resetting a pin in a loop (without any interrupt or other fonction).

Best regards,
Jey



Hi Jey,

At 500KHz we are already experience some drift in the interrupt, so any frequency higher than this will be very significant.

May I know, why do you need to toggle the IO pin instead of generating a 10Mhz PWM?

Best Regards
Travis
0 Likes
Travis
Employee
Employee
First solution authored Welcome! 500 replies posted
Jey wrote:
Hi Travis,
Thanks for your answer. I have an other question (maybe I have to create a new post?). Is there a solution to toggle an output at 10 Mhz ? I didn't succeed upper 4 MHz by setting and resetting a pin in a loop (without any interrupt or other fonction).

Best regards,
Jey



Hi Jey,

At 500KHz we are already experience some drift in the interrupt, so any frequency higher than this will be very significant.

May I know, why do you need to toggle the IO pin instead of generating a 10Mhz PWM?

Best Regards
Travis
0 Likes
Not applicable
Hi Travis,
I wanted to create a specific (23 bits) SPI communication at 1Mhz. There will be treatment (interrupts...) between two SPI frames and I am afraid that the system will not be fast enough to manage this without having any troubles at high frequencies. Does a compilation option exist to optimize the clock system for these functionnalities ?

Best Regards
Jey
0 Likes
Not applicable
I am facing the same problem: I am using a XMC 4500 relax kit and currently I am trying to communicate with a resolver to digital IC. The R2D IC (http://www.tamagawa-seiki.com/pdf/download/AU6803_04_E_Manual_DRAFT20120229.pdf) has a 3wire serial comunication protocol: a CLK signal, an SCSB to start the data out from the IC and a DATA signal. To read the information from the IC I used a PWMSP001 App, where the CLK signal is the PWM output with a duty cycle of 50% and frequency of 31 250 000Hz. I try to read the digital pin at the compare match interrupt. However, the reading takes a long time, and I cannot read the pin before the next compare match. How can I overcome this problem? Is there a way to reduce the pin reading time?
0 Likes
Not applicable
Hi, I am facing the same problem:

I am using a XMC 4500 relax kit and currently I am trying to communicate with a resolver to digital IC. The R2D IC (http://www.tamagawa-seiki.com/pdf/download/AU6803_04_E_Manual_DRAFT20120229.pdf) has a 3wire serial comunication protocol: a CLK signal, an SCSB to start the data out from the IC and a DATA signal. To read the information from the IC I used a PWMSP001 App, where the CLK signal is the PWM output with a duty cycle of 50% and frequency of 3 125 000Hz. I try to read the digital pin at the compare match interrupt. However, the reading takes a long time, and I cannot read the pin before the next compare match. How can I overcome this problem?
0 Likes