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

cross mob
DevinHuang
Level 3
Level 3
Distributor - Weikeng(GC)
100 sign-ins 10 replies posted 5 replies posted

請問TDU超時檢測,是指CNT向上計數到達TOV閥值就會自動產生中斷嗎? 我再Config _TIM添加三段設定值,就會自動執行超時機制嗎? 我對TOV不甚了解,求助各位大佬是否能讓我潛顯易懂的方式教我。

TIM_initConfig.timeout.clock = IfxGtm_Cmu_Clk_3 ;

TIM_initConfig.timeout.irqOnTimeout = TRUE;

TIM_initConfig.timeout.timeout =2.0;

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

Hi @DevinHuang ,

需要設置時鐘,TDU的counter最多可達24 bit, 雖然timeout設定sint32類型,但在賦值時會把它限製在8位大小,總之,代碼是做了簡化的操作。

2023-05-23_16h02_53.png

BR,

Jeremy

 

 

View solution in original post

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

Hi @DevinHuang ,

1) 請問TDU超時檢測,是指CNT向上計數到達TOV閥值就會自動產生中斷嗎? 

-- 是的,你這樣理解是正確的。

2)上述對於TIM_initConfig結構體的配置也沒有問題,在IfxGtm_Tim_In_init()函數中會基於配置進行相應的寄存器設置,如下所示。

/* Timeout configuration */
    if (config->timeout.timeout > 0)
    {
        float32 clockFrequency;
        sint32  timeout;
        channel->TDUV.B.TCS = config->timeout.clock;
        clockFrequency      = IfxGtm_Tim_Ch_getTimeoutClockFrequency(config->gtm, channel);

        timeout             = (uint32)(config->timeout.timeout * clockFrequency) - 1;

        if (timeout < 0)
        {
            timeout = 0;
        }
        else if (timeout >= (1 << IFX_GTM_TIM_CH_TDUV_TCS_MSK))
        {
            timeout = IFX_GTM_TIM_CH_TDUV_TCS_MSK;
            result  = FALSE;
        }

        channel->CTRL.B.TOCTRL = config->capture.mode == Ifx_Pwm_Mode_leftAligned ? IfxGtm_Tim_Timeout_risingEdge : IfxGtm_Tim_Timeout_fallingEdge;
        channel->TDUV.B.TOV    = timeout;

        IfxGtm_Tim_Ch_setTimeoutNotification(channel, config->timeout.irqOnTimeout);
    }

BR,

Jeremy

0 Likes
DevinHuang
Level 3
Level 3
Distributor - Weikeng(GC)
100 sign-ins 10 replies posted 5 replies posted

我再Config _TIM()添加 TIM_initConfig.capture.clock = IfxGtm_Cmu_Clk_2 給TIM,請問我還需要再添加timeout.clock= IfxGtm_Cmu_Clk_3給TDU嗎?

另外我看TDU的SPEC只有8bits的寬度,可是再timeout設定卻是float32類型,想問一下TOV會落在什麼精度範圍、以及單位?非常感謝你的回覆

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

Hi @DevinHuang ,

需要設置時鐘,TDU的counter最多可達24 bit, 雖然timeout設定sint32類型,但在賦值時會把它限製在8位大小,總之,代碼是做了簡化的操作。

2023-05-23_16h02_53.png

BR,

Jeremy

 

 

0 Likes