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:
(all of the other pins are unchecked)
'
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
Solved! Go to Solution.
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):
So clock for FTM is 41.94 MHz in your current configuration:
This 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):
So counter MOD register is 1.
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
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):
So clock for FTM is 41.94 MHz in your current configuration:
This 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):
So counter MOD register is 1.
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
Great information, thank you very much!