Duty Cycle Selection in PWM channels

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Duty Cycle Selection in PWM channels

跳至解决方案
4,303 次查看
marceli1
Contributor III

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?

标签 (1)
标记 (2)
0 项奖励
回复
1 解答
3,956 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Marceli,

When you create several PWM_LDD with same timer TU1, PWMx_SetDutyMS will only update the duty of selected channelx.

PWMx_SetDutyMS.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
回复
7 回复数
3,956 次查看
mjbcswitzerland
Specialist V

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

0 项奖励
回复
3,956 次查看
marceli1
Contributor III

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.

0 项奖励
回复
3,957 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Marceli,

When you create several PWM_LDD with same timer TU1, PWMx_SetDutyMS will only update the duty of selected channelx.

PWMx_SetDutyMS.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
3,956 次查看
marceli1
Contributor III

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

0 项奖励
回复
3,956 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

These six channels share the same overflow interrupt.

Interrupt vector assignments.png

TPMx_STATUS[TOF].png

OnEND.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

3,956 次查看
marceli1
Contributor III

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

0 项奖励
回复
3,956 次查看
marceli1
Contributor III

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

0 项奖励
回复