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.

[参考译文] MSPM0C1104:WDT

Guru**** 2445440 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1547559/mspm0c1104-wdt

器件型号:MSPM0C1104


工具/软件:

我正在尝试为 MSPM0C1104 MCU 编写固件代码。 

看门狗计时器 (WDT) 功能是我代码的基本要求。

MSPM0_SDK 提供了“wwdt_window_mode_periodic_reset"示“示例代码。

我稍微重写了这个示例代码、如附件中所示。 

我稍微重写了这个示例代码、如附件中所示。

我注意到主循环仅在第一个 IRQ 例程之前执行。 

因此、程序仅执行 IRQ 例程、绝不会返回到主循环。

是否有专家可以提供一些建议?

非常感谢。

wwdt_window_mode_periodic_reset.c

/**
 * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
 * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
 * @cliArgs --device "MSPM0C110X" --part "Default" --package "VSSOP-20(DGS20)" --product "mspm0_sdk@2.04.00.06"
 * @v2CliArgs --device "MSPM0C1104" --package "VSSOP-20(DGS20)" --product "mspm0_sdk@2.04.00.06"
 * @versions {"tool":"1.22.0+3893"}
 */

/**
 * Import the modules used in this configuration.
 */
const Board  = scripting.addModule("/ti/driverlib/Board");
const GPIO   = scripting.addModule("/ti/driverlib/GPIO", {}, false);
const GPIO1  = GPIO.addInstance();
const SYSCTL = scripting.addModule("/ti/driverlib/SYSCTL");
const TIMER  = scripting.addModule("/ti/driverlib/TIMER", {}, false);
const TIMER1 = TIMER.addInstance();
const WWDT   = scripting.addModule("/ti/driverlib/WWDT", {}, false);
const WWDT1  = WWDT.addInstance();

/**
 * Write custom configuration values to the imported modules.
 */
Board.configureUnused             = true;
Board.peripheral.$assign          = "DEBUGSS";
Board.peripheral.swclkPin.$assign = "PA20";
Board.peripheral.swdioPin.$assign = "PA19";

GPIO1.$name                          = "GPIO_LEDS";
GPIO1.associatedPins.create(2);
GPIO1.associatedPins[0].$name        = "USER_LED_1";
GPIO1.associatedPins[0].initialValue = "SET";
GPIO1.associatedPins[0].assignedPin  = "22";
GPIO1.associatedPins[1].$name        = "USER_TEST";
GPIO1.associatedPins[1].assignedPin  = "2";
GPIO1.associatedPins[1].initialValue = "SET";

SYSCTL.validateClkStatus = true;
SYSCTL.powerPolicy       = "STANDBY0";
SYSCTL.MFCLKEn           = true;

TIMER1.$name              = "TIMER_0";
TIMER1.timerMode          = "PERIODIC";
TIMER1.interrupts         = ["ZERO"];
TIMER1.timerClkSrc        = "LFCLK";
TIMER1.timerPeriod        = "300 ms";
TIMER1.timerClkPrescale   = 33;
TIMER1.peripheral.$assign = "TIMG14";

WWDT1.$name               = "WWDT0";
WWDT1.sleepMode           = true;
WWDT1.window0ClosedPeriod = "25";
WWDT1.peripheral.$assign  = "WWDT0";

/**
 * Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
 * version of the tool will not impact the pinmux you originally saw.  These lines can be completely deleted in order to
 * re-solve from scratch.
 */
GPIO1.associatedPins[0].pin.$suggestSolution = "PA22";
GPIO1.associatedPins[1].pin.$suggestSolution = "PA2";
SYSCTL.peripheral.$suggestSolution           = "SYSCTL";

  

wwdt_window_mode_periodic_reset.scfg

/*
 * Copyright (c) 2023, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "ti_msp_dl_config.h"

int main(void)
{
    SYSCFG_DL_init();

    /* Enable TimerG interrupts on device */
    NVIC_EnableIRQ(TIMER_0_INST_INT_IRQN);

    /* Enable sleep on exit */
    DL_SYSCTL_enableSleepOnExit();

    /* Set LED to indicate Timer counter enable */
    DL_GPIO_clearPins(
        GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN | GPIO_LEDS_USER_TEST_PIN);

    /*
     * Configures timer to be halted if CPU is halted. This ensures
     * that timer is always aligned with the WWDT so it is never serviced
     * too late or too early.
     */
    DL_Timer_setCoreHaltBehavior(TIMER_0_INST, DL_TIMER_CORE_HALT_IMMEDIATE);

    /* Start TimerG counter */
    DL_TimerG_startCounter(TIMER_0_INST);

    while (1) {
        //__WFI();
        DL_GPIO_setPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_TEST_PIN);
        delay_cycles(1000);
        DL_GPIO_clearPins(GPIO_LEDS_PORT, GPIO_LEDS_USER_TEST_PIN); 
        delay_cycles(1000);     
        //DL_WWDT_restart(WWDT0_INST);   
    }
}

void TIMER_0_INST_IRQHandler(void)
{
    switch (DL_TimerG_getPendingInterrupt(TIMER_0_INST)) {
        case DL_TIMER_IIDX_ZERO:
            /* Restart WWDT timer */
            DL_WWDT_restart(WWDT0_INST);

            /* Toggle LED to indicate WWDT reset */
            DL_GPIO_togglePins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);
            break;
        default:
            break;
    }
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    删除此行:

    :> DL_SYSCTL_enableSleepOnExit ();

    使用此设置、在第一个中断 main() 之后将永远不会再执行。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    你好、Twokey、

    同意 Bruce 的观点。 您可以看到此代码的以下说明:

    处理模式为中断模式。

    此致、

    Janz Bai

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    谢谢、这个问题已经解决。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    不用客气