Hello
I'm using a K60 Tower to generate a PWM signal, i started by a default project from SDK (simple PWM) but when i try to generate a 50Hz Square wave the Tower can't get it i don't if someone can help me to understand why, below command line that i change to get this signal :
The ftm_simple_pwm example select Bus Clock(48MHz) as FTM_SOURCE_CLOCK.
The FTM_SetupPwm() will return error due to overflow the registers:
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thanks for this feedback exactly i do the same as mentioned in the comment i change the frequency source several time with 96Mhz, 24Mhz, 1.56Mhz but i can't get my 50Hz PWM
Hi
Are you sure about the frequency source because 50Hz is no problem if you really have 1.56MHz (for example).
The API doesn't explain how to control things so you will need to study its code and work out how the pre-scaler needs to be set (I see that the pre-scaler value is read inside the call from the control register in order to calculate the value, meaning that the pre-scaler needs to be configured beforehand somehow).
Below I used the uTasker project and K60 simulator to generate 50Hzz on PRC3 (FlexTimer 0 - channel 3), using 100MHz core, 50MHz bus clock and /16 pre-scaler, which gives exactly 50Hz output as (see simulation below):
PWM_INTERRUPT_SETUP pwm_setup;
pwm_setup.int_type = PWM_INTERRUPT;
pwm_setup.int_handler = 0;
pwm_setup.pwm_mode = (PWM_SYS_CLK | PWM_PRESCALER_16 | PWM_EDGE_ALIGNED); // clock PWM timer from the system clock with /16 pre-scaler
pwm_setup.pwm_reference = (_TIMER_0 | 3); // timer module 0, channel 3
pwm_setup.pwm_frequency = PWM_FREQUENCY(50, 16); // generate 50Hz on PWM output
pwm_setup.pwm_value = _PWM_PERCENT(20, pwm_setup.pwm_frequency); // 20% PWM (high/low)
fnConfigureInterrupt((void *)&pwm_setup); // enter configuration for PWM test
If you continue having problems simply download the open source uTasker project from GITHUB since it allows simulation and higher levels of abstraction in order to avoid such problems (also code will run on almost and Kinetis parts without needing to change libraries and such - eg. if you want your K60 project to later run on a K64 or KL25 just change one define to do the same thing on the other chips).
Regards
Mark
Thanks for this feedback, finally i see that the prescale was on 1,when i set on 128 it work will with the 48Mhz source clock
Hi
What frequency is FTM_SOURCE_CLOCK and what value have you set for the FTM pre-scaler?
If it is too high to be able to generate 50Hz using maximum divide of 64k (in MOD) the function will return an error and not generate an output:
1. Check return value for errors
2. See the source code of FTM_SetupPwm() to see what it does and what causes it to fail
Regards
Mark
Complete Kinetis solutions for professional needs, training and support:http://www.utasker.com/kinetis.html
Kinetis K60:
- http://www.utasker.com/kinetis/TWR-K60N512.html
- http://www.utasker.com/kinetis/TWR-K60D100M.html
- http://www.utasker.com/kinetis/TWR-K60F120M.html
- http://www.utasker.com/kinetis/ELZET80_NET-KBED.html
- http://www.utasker.com/kinetis/ELZET80_NET-K60.html
uTasker: supporting >1'000 registered Kinetis users get products faster and cheaper to market
Request Free emergency remote desk-top consulting at http://www.utasker.com/services.html
HW timers: http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF
Open Source Version: https://github.com/uTasker/uTasker-Kinetis
Thanks for your feedback Mr Butcher, the frequency of the source clock is 48Mhz, i change it to 96Mhz, 1.56Mhz juste to see the results but i still have the same problem it can't reach below approximately 1Khz and i see any error message.