PWM Continuous mode question

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

cross mob
User16629
Level 1
Level 1
The example code for PWM generation via TOM in continuous mode is given in MPC57xxM_GTM_QuickStartGuide_Rev2_2014_AN4351.pdf and it goes like this:

MODULE_GTM.TOM[TOM_INSTANCE].CH0.CM0.U = 0x0000FFFF; //Period
MODULE_GTM.TOM[TOM_INSTANCE].CH0.CM1.U = 0x00004000;
MODULE_GTM.TOM[TOM_INSTANCE].CH0.CTRL.U = 0x00100800; //ch0 cont mode, SL=1, RST_CCU0=1
MODULE_GTM.TOM[TOM_INSTANCE].TGC0_OUTEN_CTRL.U = 0x000000AA;
MODULE_GTM.TOM[TOM_INSTANCE].TGC0_OUTEN_STAT.U = 0x000000AA;
MODULE_GTM.TOM[TOM_INSTANCE].TGC0_ENDIS_CTRL.U = 0x000000AA;
MODULE_GTM.TOM[TOM_INSTANCE].TGC0_ENDIS_STAT.U = 0x000000AA;

This works fine and it generates a PWM with the stated period and duty cycle in CM0 and CM1 respectively.

What I am finding is that changing the CM0 value to anything other than 0x0000FFFF will not generate the expected period. For example a value of 0x8000 (32768) should give me a PWM with period of 163840 ns given a 5ns clock selection (200MHz). But it does not. I get some strange waves.

On further examination of the CN0 register I see that it does not get reset when it gets to 0x8000 but just keeps counting on.

How do I generate a PWM of a chosen period with the TOM in continuous mode?

Any help would be great.
0 Likes
1 Reply
User16629
Level 1
Level 1
Just figured out what the problem was by pure serendipity. Changing the CTRL reg SL value to zero fixes the issue.
MODULE_GTM.TOM[TOM_INSTANCE].CH0.CTRL.U = 0x00000800; //ch0 cont mode, SL=0 RST_CCU0=1

Now I can get the PWM of any period. I am using VLAB with the TC39x toolset. Don't know if this is a bug there.
0 Likes