恒定相移 pwm 配置 TC377

公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

Tip / 登入 to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Translation_Bot
Community Manager
Community Manager
Community Manager

嗨,

我想使用 TOM 模块配置 PWM 以实现恒定相移,我使用的是 tc377tp 控制器,

我想知道如何配置。 CAN 提供要配置的示例代码

注意:我没有使用 ATOM

0 点赞
1 解答
Translation_Bot
Community Manager
Community Manager
Community Manager

你好 Nambi,

 

我已经解决了我面临的问题。

问候,

Nareshkumar

在原帖中查看解决方案

0 点赞
5 回复数
Translation_Bot
Community Manager
Community Manager
Community Manager

嗨,

您CAN分享预期的波形?

您 CAN 检查 UM 中的“28.16.3 相移控制单元”部分。

最诚挚的问候。

0 点赞
Translation_Bot
Community Manager
Community Manager
Community Manager

嗨,

我已经读完了你建议我不使用 tim 模块的那一章,

我正在使用 TOM 模块

0 点赞
Translation_Bot
Community Manager
Community Manager
Community Manager

/* pwm.c
*

* 创建于:2023 年 10 月 7 日 * 作者:40030868
*/


#include " pwm.h "
#include " ifxgtm_tom.h "
#include " ifxgtm_reg.H "
#include " ifxgtm_tom_pwm.h "
#include ifxgtm_pinmap.h #define topaSwitch ifxgtm_tom0_1_tout54_p21_3_out #define topswitch ifxgtm_tom0_3_tout56_p21_5_out #define topcSwitch ifxgtm_tom0_14_tout6_p02_6_out bopswitch " ifxgt "
m_tom0_5_out #define aSwitc &
&
&
&ifxgtm_tom0_2_tout55_p21_4_out
#define botbSwitch ifxgtm_tom0_ & 13_tout5_p02_5_out #define botcSwitch ifxgtm_tom0_6_tout59_p20_0_out #define disable_CLOCK 0x555555u #define SUCCESS 1u #define 重置 0u static uint8 Tom1Init (gtmconfig0_d *stTom);static uint8 g_stat_ucclockstatus_D = 0u;static ifx_timerValue g_stat_ulntomdutycle_TA = 0u;static ifx_timerValue g_stat_ulntomdutycycle_
TB &






= 0u;
static ifx_timerValue g_stat_ulntomdutycycle_TC = 0u;ifxgtm_tom_timer_config sttimerConfig_d;static app_gtmtompwmhl_D g_stat_gtmtom1_D;static gtmconfig0_D;static gtmconfig0_d g_stat_con_con
fig [1] = {{INV_SWITCHING_FRQUENCY、INV_DEADTIME、ifxgtm_tom_0、inv_MAX_TOM_CHANNEL、ifxgtm_tom_ch_0、}}};


{TopASwitch, TopBSwitch, TopCSwitch} {BotASwitch, BotBSwitch, BotCSwitch}

 

 


uint8 gtmtom1pwm_init_D (void)
{
uint8 ucTom1Status = 0u;
// uint8 ucTomStatus = 0u;
g_stat_ucClockStatus_D = Enable_GTMClock_Inv_D(); /*Enable CMU Clock*/
ucTom1Status = Tom1Init(&g_stat_Con_Config[0]); /*Enable TOM1 Channel*/
ucTom1Status = ucTom1Status&g_stat_ucClockStatus_D; /*Compute the return variable*/
return ucTom1Status;
}

 

 

static uint8 Tom1Init (gtmconfig0_d *stTom) {uint8 uctomStatus = RESET,ucLoopCounter =RESET;

/* st_gTM TOM 配置 *///ifxgtm_tom_timer_config sttimer_config sttimerConfig;/
/ifxgtm_tom_tom_tom_CHANNEL];ifxgtm_tom_tom_toutmApp st_acoutx [INV_MAX_TOM_CHANNEL];ifxgtm_tom_tom_TOUTMApp st_acoutx [INV_MAX_TOM_CHANNEL];ifxgtm_tom_tom_TOUTMApp];


/****************TOM 频率配置***********/
ifxgtm_timer_timer_initConfig(&sttimerConfig_D,MODULE_GTM);/*复制计时器通道的默认配置*/ sttimerConfig_d.base.minResolution = sttom-m_fSwitchingFrequency;/*更新默认切换频率*/ sttimerConfig_d.base.minResolution &
>
= 1.0F /sttimerConfig_d.base.Frequency; /*计算脉冲的最小分辨率*/ sttimerC
onfig_d.tom = sttom-> m_ettom;/*选择 TOM 组*/ uctomStatus = ifxgtm_timer_init (g_stat_gtmtom1_d.drivers.timer,
& &sttimerConfig_D); /*配置 TOM 模块*/ /******************************************************************** TOM 频道配置
*********/ ifxgtm_pwmhl_initConfig (stpwmhlconfig_D);/*复制默认 PWM 通道配置*/ for (; ucloopCounter INV_MAX_TOM_CHANNEL; ucloopCounter++) stpwmhlconfig_d.timer =

&
<
{ /* Copy the Channel Details*/
st_aCcx[ucLoopCounter]= stTom->m_stCcx[ucLoopCounter];
st_aCoutx[ucLoopCounter]= stTom->m_stCoutx[ucLoopCounter];
}
&g_stat_gtmtom1_d.drivers.timer; /*选择计时器*/ stpwmhlconfig_d.tom = sttimerConfig_d.tom
; /*TOM 模块选择*/ stpwmhlconfig_d.base.deadTime =
sttom-m_fDeadTime;/*按门切换时间计算的死区时间*/ stpwmhlconfig_d.base.channelCount >
= INV_MAX_TOM_
CHANNEL;/*复制 Max TOM 频道*/ stpwmhlconfig_d.ccx = st_ & accx [0];/*复制 st_accx Pin*/ stpwmhlconfig_d.coutx = st_acoutx [0];/*复制 COUT 引脚*/ stpwmhlconfig_d.base.outputMode = ifxport_OutputMode = ifxport_OutputMode _pushPull;
&

uctomStatus & = ifxgtm_tom_pwmhl_init (g_stat_gtmtom1_d.drivers.pwm,& &stpwmhlconfig_d);/*配置 PWM 信道寄存器*/ uctomStatus = ifxgtm_tom_pwmhl_setMode (g_stat_gtmtom1_d.drivers.pwm,
&& ifx_pwm_mode_centerAligned);/*将 PWM 计数配置为中心对齐模式*/ ifxgtm_tom_timer_run (g_stat_gtmtom1_d.drivers.timer);
& /*启动 PWM 计时器*/ 返回 uctomStatus;}

extern uint8 enable_gtmclock_inv_d (void)
{
//boolean bInterructState = 0u;ifx_gtm *st_gTM = MODULE_GTM;uint8 ucclkStatus = 0u;
ifxgtm_enable (st_gTM);/*启用 st_gTM 模块时钟。&

st_gtm 模块时钟 = SPB Clock*/ g_stat_gtmtom1_d.info.gtmfreq = ifxgtm_cmu_getModuleFrequency (st_
gtm);


ifxgtm_cmu_enableClocks(st_gtm,DISABLE_CLOCKS);/*配置前禁用 CMU 时钟*/ /* 设置全局时钟频率 */ ifxgtm_cmu_setgclkFrequency (st_gtmtom1_d.info.gtmfreq);

/*配置 CMU CLK 0 以获取 TIM 模块控制导频信号*/ g_stat_gtmt
om1_d.info.gtmgclkFreq = ifxgtm_cmu_getgclkFrequency (st_gtm);/*读取并存储在数据结构中以备将来使用*/

ifxgtm_cmu_setclkFrequency(st_gtm、ifxgtm_cmu_clk_0、g_stat_gtmtom1_d.info.gtmgclkFreq);
g_stat_gtmtom1_d.info.gtmcmuclk0Freq = ifxgtm_cmu_getclkFrequency(st_gtm,ifxgtm_cmu_clk_0,TRUE);

/* 再次启用中断 */
ifxgtm_cmu_enableClocks (st_GTM、ifxgtm_CMU_CLKEN_FXCLK | ifxgtm_cmu_CLKEN_CLKEN_CLK0);/*启用 CMU_FXCLK1*/ ucclkStatus = 成功;返回 ucclkStatus;}


 

void updateDutycycle_D(float32 开关频率、uint8 ucdutycycle_TA、uint8 ucdutycycle_TB、uint8 ucdutycycle_tc){uint8 FrequencycleUpdation = 重置;//ifxport_toglePin (LED3);ifxgtm_tom_timer *sttimer = g_stat_gtomtomer = g_stat_gtomtomer 1_d.drivers.timer;



&
ifxgtm_tom_pwmHL *stpwmHL = g_stat_gtmtom1_d.drivers.pwm;&
ifx_timerValue UlntonTime [INV_MAX_TOM_CHANNEL];

uint32 actualdutycycle=reset、dutycycle_ta=reset、dutycycle_tb=reset、dutycycle_tc=reset;

dutycycle_ta= (uint32) ucdutycycle_ta;dutycycle_tb =( uint32) ucdutycycle_TB;dutycycle_tc =( uint32) ucdutycycle_tc;

frequencyUpdation = ifxgtm_timer_setFrequency(stTimer,开关频率);stpwmhl-base.maxpulse=sttimer-base.stpwm
hl-base.minPulse;actualdutycycle=sttimer-base.period-stimer-base.period/percentage_factor;g_stat_ulntomdutycycle_cleta = actualdutycycle=sttimer-> base.period*dutycycle_ta;g_stat_ulntomdutycle_TB = actualdutycle*dutycle_tb;g_stat_ulntomdutycle_tc = actualdutycle* > >
>


Dutycycle_tc;

ulntonTime [0] = g_stat_ulntomdutycycle_ta;/*Channel 1 st_accx,Cout dutyCycle*/ ulntonTime [1] = g_stat_ulntomdutycycle_tc;//for (uint8 uc
loopCounter = 0;ucloopCounter 3; ucLoopCounter++

<
{
IfxGtm_Tom_Timer_disableUpdate(stTimer); /*Stop Data Updation from Shadow Register to CM0 and CM1*/
IfxGtm_Tom_PwmHl_setOnTime(stPwmHl, &ulnTonTime[0]); /*Update DutyCycle in Shadow Register*/
IfxGtm_Tom_Timer_applyUpdate(stTimer); /*Enable Data Updation from Shadow Register to CM0 and CM1*/
//}

}

 

 

 

我会加上 .h 内容如下

 

 

/* pwm.h
*

* 创建于:2023 年 10 月 7 日 * 作者:40030868
*/

#ifndef SERVICELAYER_PWM_H_
#define SERVICELAYER_PWM_H_
#include ifx_T ypes.H < >
#include " sysse/bsp/bsp.h #include i "
fxgtm_tom.h " "
#include " ifxgtm_reg.H "
#include " ifxgtm_regdef.h "
#include ifxgtm_tom_pwm.H #include ifxgtm_pinmap.H #include ifxgtm_tom_pwmHL.H #define INV_SWITCHIN " G_FR "
QUENCY 85000U #define INV_DEADTIME 0.00000030f " "
" "


#define INV_MAX_TOM_CHANNEL 3u #define PERCENTAGE_FACTOR 100u

 


typedef struct
{struct
{
float32 gtmFreq;
float32 gtmGclkFreq;
float32 gtmCmuClk0Freq;
float32 gtmCmuClk1Freq;
} info;struct drivers;
struct isrCoun
ter;} app
{
IfxGtm_Tom_Timer timer;
IfxGtm_Tom_PwmHl pwm;
} _gtmtompwmhl
_D
{
uint32 slotTimer;
};


typedef 结构
{
float32 m_fSwitchingFrequency;
float32 m_fDeadTime;
IfxGtm_Tom m_etTom;
uint8 m_ucNumberOfChannel;
IfxGtm_Tom_Ch m_eTimerChannel;
IfxGtm_Tom_ToutMapP m_stCcx[INV_MAX_TOM_CHANNEL];
IfxGtm_Tom_ToutMapP m_stCoutx[INV_MAX_TOM_CHANNEL];
} gtmconfig0_D;

void updateDutycycle_D(float32 开关频率、uint8 ucdutycycle_ta、uint8 ucdutycycle_tb、uint8 ucdutycycle_tc);extern uintm1pwm_init_D(void);extern uint8 enable_gtmclock_inv_d (void);#endif /* SERVICELAYCLE_D (void);extern uint8 enable_gtmclock_inv_D (void);/* ER_PWM_H_ */


 

 

 

我想反向为顶部生成 3 pwm,为底部生成 3 pwm,所以我这样配置,但我没有得到这个引脚的 pwm(TopCSwitch,BotBSwitch),我不知道为什么,因为我引用了多个代码进行配置 CAN 请您帮助我。

注意:相移问题解决了,现在我面临着这个问题

 

 

0 点赞
Translation_Bot
Community Manager
Community Manager
Community Manager

嗨,

既然最初的问题已经解决了,你能把它移到一个新话题吗?

根据我们的理解,这段代码可以按预期运行 TopcSwitch、BotbSwitch 预期的 4 个输出。这是对的吗?

请提供预期的波形和观察到的波形。

最诚挚的问候。

0 点赞
Translation_Bot
Community Manager
Community Manager
Community Manager

你好 Nambi,

 

我已经解决了我面临的问题。

问候,

Nareshkumar

0 点赞