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.

[参考译文] MSPM0G3507:电源策略管理

Guru**** 2625265 points

Other Parts Discussed in Thread: MSPM0G3507

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1340689/mspm0g3507-power-policy-management

器件型号:MSPM0G3507

大家好、

我将尝试在我们的设计中使用 MSPM0G3507实现低功耗模式。 关于这一点、我无法实现通过 TIMG0中断将 MCU 唤醒。 我可以在停止或待机模式下通过此 IRQ 唤醒 MCU 吗? 因为 MCU 数据表的第98页中提到 PD0 IRQ 作为唤醒源。  顺便说一下、第1361页提到 TIMG0由 PD0供电。

我正在使用 MSPM0G3507 EVM、这段代码

/*
 * Copyright (c) 2021, 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/driverlib/m0p/dl_core.h"
#include "ti_msp_dl_config.h"



void init_all() {
  SYSCFG_DL_init();
  NVIC_EnableIRQ(TIMER_0_INST_INT_IRQN);
  NVIC_EnableIRQ(GPIO_SW_GPIOA_INT_IRQN);
  NVIC_EnableIRQ(GPIO_SW_GPIOB_INT_IRQN);

  DL_TimerG_startCounter(TIMER_0_INST);
  DL_SYSCTL_disableSleepOnExit();
}

int main(void) {
  int j = 0;
  int k = 0;
  init_all();
  while (1) {
    j++;
    k = j;
    k--;
    // DL_SYSCTL_setPowerPolicySHUTDOWN();
    // DL_SYSCTL_setPowerPolicySTOP0();
    DL_SYSCTL_setPowerPolicySTANDBY0();
    // DL_SYSCTL_setPowerPolicyRUN0SLEEP0();

    __WFI();
    init_all();
  }
}

void GROUP1_IRQHandler(void) {
  switch (DL_Interrupt_getPendingGroup(DL_INTERRUPT_GROUP_1)) {
  case GPIO_SW_GPIOA_INT_IIDX:
    /* If SW is high, turn the LED off */
    if (DL_GPIO_readPins(GPIO_SW_USER_SWITCH_1_PORT,
                         GPIO_SW_USER_SWITCH_1_PIN)) {
      DL_GPIO_setPins(LED_GPIO_PORT, LED_GPIO_LED_01_PIN);
    }
    /* Otherwise, turn the LED on */
    else {
      DL_GPIO_clearPins(LED_GPIO_PORT, LED_GPIO_LED_01_PIN);
    }
    break;
  case GPIO_SW_GPIOB_INT_IIDX:
    /* If SW is high, turn the LED off */
    if (DL_GPIO_readPins(GPIO_SW_USER_SWITCH_1_PORT,
                         GPIO_SW_USER_SWITCH_2_PIN)) {
      DL_GPIO_setPins(LED_GPIO_PORT, LED_GPIO_LED_01_PIN);
    }
    /* Otherwise, turn the LED on */
    else {
      DL_GPIO_clearPins(LED_GPIO_PORT, LED_GPIO_LED_01_PIN);
    }
    break;
  case GPIO_SW_CAN_RX_EM_IIDX:
    /* If SW is high, turn the LED off */
    if (DL_GPIO_readPins(GPIO_SW_USER_SWITCH_1_PORT,
                         GPIO_SW_USER_SWITCH_2_PIN)) {
      DL_GPIO_setPins(LED_GPIO_PORT, LED_GPIO_LED_01_PIN);
    }
    /* Otherwise, turn the LED on */
    else {
      DL_GPIO_clearPins(LED_GPIO_PORT, LED_GPIO_LED_01_PIN);
    }

    break;
  }
}

/**
 * STANDBY0 Clock, runs all the time at the same frequency
 */
void TIMER_0_INST_IRQHandler(void) {
  static uint32_t count = 0;

  switch (DL_TimerG_getPendingInterrupt(TIMER_0_INST)) {
  case DL_TIMERG_IIDX_ZERO:
    count++;
    if (count > 2) {
      DL_GPIO_togglePins(LED_GPIO_2_PORT, LED_GPIO_2_LED_3_PIN);
      count=0;
    }
    break;
  default:
    break;
  }
}

谢谢

尼古拉

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

    您好、Nicolas、

    您是说器件没有被 ISR 唤醒/GPIO 没有切换? TimerG0可在 STANDBY 和 STOP 模式期间选择性启用、因此我希望它能从这些功耗模式中唤醒。

    它与中的示例类似:

    [SDK 安装路径]\mspm0_sdk_1_30_00_03\examples\nortos\LP_MSPM0G3507\driverlib\SYSCTL_POWER_POLICY_SLEEP_TO_STANDBY

    演示将器件从 STANDBY0唤醒以切换 GPIO、并定期更改低功耗模式。 您可能需要将代码与该示例进行比较、看看是不是由于某种差异导致了您看到的行为。

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

    尊敬的 Dylan:

    我根据您推荐的示例重新编写了该代码。 错误的地方是 MCU 每次执行___ WFI ()指令时都在执行初始化例程。  

    谢谢!