Hi,
I need use one timer with four channels operating on the same frequency, however each channels I need set duty cycle independently out of other channels. Is it possible or I need find micro with four timers?
Solved! Go to Solution.
Hi Marceli,
When you create several PWM_LDD with same timer TU1, PWMx_SetDutyMS will only update the duty of selected channelx.
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi
Each timer has a single frequency but each of its channels can generate a different duty cycle at this frequency.
See http://www.utasker.com/docs/uTasker/uTaskerHWTimers.PDF (chapter 5 and appendix - page 20) for more details.
Regards
Mark
Hi Mark,
I am using MKL25Z timer and PE approach. I am able create PWM2 for next channel with the same timer TU1.
I am not sure when changing duty cycle using:
LDD_TError PWM2_SetDutyMS(LDD_TDeviceData *DeviceDataPtr, uint16_t Time){..}
calling at OnEnd event I will change for only PWM2 set channel.
Hi Marceli,
When you create several PWM_LDD with same timer TU1, PWMx_SetDutyMS will only update the duty of selected channelx.
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Robin,
thank you. To avoid output noise I need change duty cycle in the event OnEnd period and this will be separate for each channel done. Problem can be I will get six channels interrupts at the same time on the end of the same period. Will I lost some of interrupts or I need to setup priorities for them and how?
Kind Regards,
Marceli
These six channels share the same overflow interrupt.
Best Regards,
Robin
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Robin,
PE is not allowing me to change initially period timer TU1 while is linked with PWM six channels. It is even Counter restart is in "On-match" mode. Can I make own method to change period for all channels in timer TU1?
#include "TPM_PDD.h"
LDD_TError TU1_SetPeriodTicks(LDD_TDeviceData *DeviceDataPtr, uint16_t Ticks)
{
(void)DeviceDataPtr; /* Parameter is not used, suppress unused argument warning */
/* Parameter test - this test can be disabled by setting the "Ignore range checking"
property to the "yes" value in the "Configuration inspector" */
if ((Ticks > 65535U) || (Ticks == 1U)) { /* Is the given value out of range? */
return ERR_PARAM_TICKS; /* If yes then error */
}
TPM_PDD_WriteModuloReg(TPM0_BASE_PTR, (uint16_t)(--Ticks));
return ERR_OK; /* OK */
}
Regards,
Marceli
Hi Robin,
Thank you, this explains process order very well. Only need to pass channel's duty cycle value at OnEnd channel event.
Regards,
Marceli