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

cross mob
Bertxu
Level 3
Level 3
250 sign-ins 10 replies posted 100 sign-ins
hi, 使用公板使用例程GTM_TIM_Capture_1_KIT_TC397_TFT 时出现以下问题: 把PWM的输出端,与捕获端断开此时开机,抓取以下值三个值为0,正常,接上PWM的输出端和捕获端,能够正确的读出以下三个值,但此时断开输出端和捕获端,还是能够正常读出以下三个值(理论上断开后读出的值为0),请问这是什么原因导致的?谢谢! g_measuredPwmPeriod = IfxGtm_Tim_In_getPeriodSecond(&g_driverTIM); /* Get the period of the PWM signal */ Ifx_Console_print("g_measuredPwmPeriod: %f\n\r",g_measuredPwmPeriod); g_measuredPwmFreq_Hz = 1 / g_measuredPwmPeriod; /* Calculate the frequency */ Ifx_Console_print("g_measuredPwmFreq_Hz : %f\n\r",g_measuredPwmFreq_Hz); g_measuredPwmDutyCycle = IfxGtm_Tim_In_getDutyPercent(&g_driverTIM, &g_dataCoherent); /* Get the duty cycle */ Ifx_Console_print("g_measuredPwmDutyCycle: %f\n\r",g_measuredPwmDutyCycle);
0 Likes
1 Solution
Jeremy_Z
Moderator
Moderator
Moderator
250 sign-ins 100 likes received 750 replies posted

Hi @Bertxu ,

1) 不会触发NEWVAL事件。

我再强调一遍,请具体请参考TIM的PTWM模式的介绍。

BR,

Jeremy

View solution in original post

0 Likes
6 Replies
Bertxu
Level 3
Level 3
250 sign-ins 10 replies posted 100 sign-ins

读取代码如下:

g_measuredPwmPeriod = IfxGtm_Tim_In_getPeriodSecond(&g_driverTIM); /* Get the period of the PWM signal */ Ifx_Console_print("g_measuredPwmPeriod: %f\n\r",g_measuredPwmPeriod);

g_measuredPwmFreq_Hz = 1 / g_measuredPwmPeriod; /* Calculate the frequency */ Ifx_Console_print("g_measuredPwmFreq_Hz : %f\n\r",g_measuredPwmFreq_Hz);

g_measuredPwmDutyCycle = IfxGtm_Tim_In_getDutyPercent(&g_driverTIM, &g_dataCoherent); /* Get the duty cycle */

Ifx_Console_print("g_measuredPwmDutyCycle: %f\n\r",g_measuredPwmDutyCycle);

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
250 sign-ins 100 likes received 750 replies posted

Hi @Bertxu ,

g_driverTIM结构体中的pulseLengthTick和periodTick只有在TIM的NEWVAL事件触发后才会更新,如果事件一直没有出现,它就保持前面的值不变。

BR,

Jeremy

0 Likes
Bertxu
Level 3
Level 3
250 sign-ins 10 replies posted 100 sign-ins

Hi, :

请问,TIM的NEWVAL事件是否触发,是随PWM的变而化触发吗?还是通过其他事件触发?

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
250 sign-ins 100 likes received 750 replies posted

Hi @Bertxu ,

是的,具体请参考TIM的PTWM模式的介绍。

BR,

Jeremy

0 Likes

Hi, 

请问,TIM的NEWVAL事件随PWM变化触发,那把PWM输出端断开或(停止PWM的产生),这样应该使TIM的NEWVAL事件触发?

但从目前实验看当断开PWM输出端时,并没有触发事件,读出的值(与连接时)没有变化。如果在每次检测时 先执行init_TIM(),后再去读取,这时值会随外部的PWM变化而变化。

0 Likes
Jeremy_Z
Moderator
Moderator
Moderator
250 sign-ins 100 likes received 750 replies posted

Hi @Bertxu ,

1) 不会触发NEWVAL事件。

我再强调一遍,请具体请参考TIM的PTWM模式的介绍。

BR,

Jeremy

0 Likes