This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

dsp c5517 看门狗的时钟的选择及如何设置喂狗的时间?

Expert 2137 points


工程师您好:我现在在使用c5517看门狗功能,遇到如下问题。

(1)其看门狗的时钟是TIM2的时钟吗?

(2)喂狗的时间是如何计算的?

(3)如何喂狗?

  • (1)是的,Timer2配置为Watchdog模式。

    (2)有counter, period寄存器计数。

    (3) 14.3.2 Watchdog Timer Operation里有喂狗说明。
    http://www.ti.com/lit/ug/spruh16b/spruh16b.pdf

    CSL里有例程。 

  • 我知道是count period寄存器,是如何计算的?就是对应时间计算公式是什么啊?具体呗

  • counter*period

  • 再除以输入timer2时钟?

  • 您好 我测试了  发现counter计数器设置的大小与看门狗的时间无关,只与prescale有关 而且还是prescale+1的关系。  

    /* Watchdog timer Object structure */
    CSL_WdtObj wdtObj;
    CSL_Status status;
    CSL_WdtHandle hWdt = NULL;
    WDTIM_Config hwConfig,getConfig;

    T2INSR=0x0006; //选择时钟

    /* Open the WDTIM module */
    hWdt = (CSL_WdtObj *)WDTIM_open(WDT_INST_0, &wdtObj, &status);
    if(NULL == hWdt)
    {
    UART_Str("WDTIM: Open for the watchdog Failed\n");
    }
    else
    {
    UART_Str("WDTIM: Open for the watchdog Passed\n");
    }

    hwConfig.counter = 12000; //开始值0xFFFF
    hwConfig.prescale = 1; //预分频寄存器0x0FFF

    /* Configure the watch dog timer */
    status = WDTIM_config(hWdt, &hwConfig);
    if(CSL_SOK != status)
    {
    UART_Str("WDTIM: Config for the watchdog Failed\n");
    }
    else
    {
    UART_Str("WDTIM: Config for the watchdog Passed\n");
    }

    /* Read the configured values */
    status = WDTIM_getConfig(hWdt, &getConfig);
    if(CSL_SOK != status)
    {
    UART_Str("WDTIM: Get Config for the watchdog Failed\n");
    }
    else
    {
    UART_Str("WDTIM: Get Config for the watchdog Passed\n");
    }

    /* Verify the configurations */
    if((hwConfig.counter != getConfig.counter)||(hwConfig.prescale != getConfig.prescale))
    {
    UART_Str("WDTIM: Get and Set Configuration Mis-Matched \n");
    }
    else
    {
    UART_Str("WDTIM: Get and Set Configuration Matched \n");
    }

    /* Start the watch dog timer */
    status = WDTIM_start(hWdt);

  • counter怎么会没用呢?

    手册里写的The combination of the 16-bit counter with the 16-bit prescaler allows for a maximum countdown value of 4,294,967,296.