Unable to get PWM to work with ext crystal-only configuration

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to get PWM to work with ext crystal-only configuration

Jump to solution
944 Views
dave408
Senior Contributor II

I've been reading up on the various clock configurations, and currently I am trying out a project for fun that uses the UART at 115.2kbps and a PWM channel at 20MHz.  I only want to use a 32khz external crystal, connected to EXTAL32.  I am using a FRDM-K64F for testing.

 

I believe I have all of the clock configuration parameters set properly.  My main loop sends 0x55 over the UART and that works as expected.  However, when I try to start my PWM channel, nothing happens.  I'm using it just as I do in other projects (which work), and I basically just call:

 

FTM_DRV_PwmStart(FSL_FLEXTIMER1, &flexTimer1_ChnConfig0, 1);

 

I'm using the following FTM configuration:

 

41663_41663.pngpastedImage_1.png

41664_41664.pngpastedImage_2.png

(all of the other pins are unchecked)

 

41665_41665.pngpastedImage_3.png'

These are the settings I have used in other projects, which do work properly.


I've attached my project, in case anyone has time to import it and take a look.  Thank you!

Original Attachment has been moved to: KDS3_crystal_test.zip

Labels (1)
1 Solution
685 Views
isaacavila
NXP Employee
NXP Employee

Hello Dave,

Actually your PE configuration is correct, but it is not possible to get a PWM frequency of 20 MHz using current clock configuration.

  As you can read in K64 Sub-Family Reference Manual (http://cache.freescale.com/files/microcontrollers/doc/ref_manual/K64P144M120SF5RM.pdf) in section 3.8.2.2 External Clock Options, FTM is clocked to bus clock (FTM refers to it as System Clock):

FTM Specifications.jpg

So clock for FTM is 41.94 MHz in your current configuration:

FTM Source Clock.jpgThis way, your FTM module will increment one unit every 23 nS approximately (1 / 41.94MHz).

If you want a 20MHz-PWM signal, your signal period must be 50 nS.

To achieve this, MOD value (value in which TPM counter will reset its value) is calculated as follows (taking in mind that initial counter value is 0: CNTIN = 0):

MOD Calculation.jpg

So counter MOD register is 1.

MOD and CNV Values.jpg

So every clock pulse that increments FTM module, counter will be reset and cannot set/clear its respective output level.

So it is not possible to control a 20MHz-PWM signal using current clock settings.

I hope this can help you,

Best Regards,

Isaac Avila

View solution in original post

2 Replies
686 Views
isaacavila
NXP Employee
NXP Employee

Hello Dave,

Actually your PE configuration is correct, but it is not possible to get a PWM frequency of 20 MHz using current clock configuration.

  As you can read in K64 Sub-Family Reference Manual (http://cache.freescale.com/files/microcontrollers/doc/ref_manual/K64P144M120SF5RM.pdf) in section 3.8.2.2 External Clock Options, FTM is clocked to bus clock (FTM refers to it as System Clock):

FTM Specifications.jpg

So clock for FTM is 41.94 MHz in your current configuration:

FTM Source Clock.jpgThis way, your FTM module will increment one unit every 23 nS approximately (1 / 41.94MHz).

If you want a 20MHz-PWM signal, your signal period must be 50 nS.

To achieve this, MOD value (value in which TPM counter will reset its value) is calculated as follows (taking in mind that initial counter value is 0: CNTIN = 0):

MOD Calculation.jpg

So counter MOD register is 1.

MOD and CNV Values.jpg

So every clock pulse that increments FTM module, counter will be reset and cannot set/clear its respective output level.

So it is not possible to control a 20MHz-PWM signal using current clock settings.

I hope this can help you,

Best Regards,

Isaac Avila

685 Views
dave408
Senior Contributor II

Great information, thank you very much!

0 Kudos