....
Hello,
I found other libs for this and started to use it, but can't still run PWM on the pin PTC1 (in the doc it uses TPM module 0 Channel 0). I use the next code:
tpm_general_config_t tpmCfg =
{
.isDBGMode = true,//0,
.isGlobalTimeBase = 0,
.isTriggerMode = 0,
.isStopCountOnOveflow = 0,
.isCountReloadOnTrig = true,//0,
.triggerSource = kTpmTrigSel8//kTpmTrigSel0,
};
tpm_pwm_param_t param =
{
.mode = kTpmEdgeAlignedPWM,
.edgeMode = kTpmHighTrue,
.uFrequencyHZ = 100000U,
.uDutyCyclePercent = 50U,
};
tpm_status_t status;
PORT_HAL_SetMuxMode(PORTC,1u,kPortMuxAlt2);
TPM_DRV_SetClock(TPM0_IDX, kTpmClockSourceExternalClk, kTpmDividedBy2 );
status = TPM_DRV_Init(TPM0_IDX, &tpmCfg);
status = TPM_DRV_PwmStart(TPM0_IDX, ¶m, 0);
...
What is wrong? I don't see any output on PTC1, all time 0 Volts.
Hi Sergii
TPM0_CH0 is ALT 4 on PTC1 and not ALT 2.
Regards
Mark
Kinetis: http://www.utasker.com/kinetis.html
Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M
For better, faster, cheaper product developments consider the uTasker developer's version, professional Kinetis support, one-on-one training and complete fast-track project solutions to set you apart from the herd : http://www.utasker.com/support.html
Hello,
Thanks,it was helped. Now works.
I have other issue. I setuped PWM on frequency 50 Hz.
I can control duty cycle from 0 to 100% with precision 1. For example 0,1,2,3,4 ..100.
Can I control t wit better precision? For example 0,2%.
Sergii
The PWM precision depends on the counter match value used to generate your base frequency. Since you have a low frequency the counter match will be a high value (optimally it should be set - using an appropriate clock pre-scaler - to be a large value as close to 0xffff as possible. This will allow high precision (in the best case approaching 0.002%).
Therefore, check the counter match value presently used, optimise it if possible, and then make use of the fine control (in case the API that you are presently using is restricting it).
Regards
Mark
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html
Thanks for the response. Could you give some example how to do it?
пт, 13 апр. 2018 г., 3:02 mjbcswitzerland <admin@community.nxp.com>:
NXP Community
<https://community.freescale.com/resources/statics/1000/35400-NXP-Community-Email-banner-600x75.jpg>
Re: How could I run PWM on MKW01Z128 pin PTC1
reply from Mark Butcher
<https://community.nxp.com/people/mjbcswitzerland?et=watches.email.thread>
in Kinetis Microcontrollers - View the full discussion
<https://community.nxp.com/message/1005043?commentID=1005043&et=watches.email.thread#comment-1005043>
Hi
See what value is being written to the FTMx_MOD register (this is your time base).
Then you can control your output channel's FTM_CV register with value from 0...FTMx_MOD value and its resolution is given by (1/FTMx_MOD * 100)%
Regards
Mark
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html
Thank you for the response.
Is it possible to do it from API?
I use TPM_DRV_* API to set up PWM...
And one more things.
How is possible to run watch dog for MKW01Z128? I tried lib #include "fsl_wdog_driver.h", but It can't find WDOG_Type structure, it looks like this structure is not exist for this mcu.
and how can I use sleep mode? (couldn't find API)
Sergii
I am sorry but I don't use the APIs so can't help more.
Regards
Mark
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html