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.

[参考译文] TM4C129ENCPDT:重置 HIB 模块中的夯土器

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1110471/tm4c129encpdt-resetting-tampers-in-hib-module

器件型号:TM4C129ENCPDT

你(们)好

我很明显遗漏了一些东西、我看到了几篇关于同一主题的文章、并阅读了数据表、但我似乎无法清除 HIBTPSTAT、希望鹰眼的 amonst 你会发现我的错误。

我想使用 TMPR0来指示我的器件是否已被连接、MCU 不会处于睡眠状态、因此无需将其唤醒、我只想确保与事件相关的必要内务处理得到处理、 但是 、尽管 我在 HIBTPCTL 中似乎设置了 TPCLR、HIB_TPSTAT 仍保持置1。

bool
HibernateInitialisation(const uint32_t sys_clock_frequency)
{
    uint32_t status;

    bool was_on = false;

    //
    // Enable the hibernate module.
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);

    if (MAP_HibernateIsActive())
    {
        was_on = true;
        //
        // Hibernation module is already active, this could mean that the processor is waking
        // from a hibernation. Read the status bits to see what caused the wake.  Clear the wake
        // source so that the device can be put into hibernation again.
        //
        status = MAP_HibernateIntStatus(false);
        MAP_HibernateIntClear(status);
    }

    //
    // Configure Hibernate module clock.
    //
    MAP_HibernateEnableExpClk(sys_clock_frequency);

    //
    // Configure the module clock source.
    //
    MAP_HibernateClockConfig(HIBERNATE_OSC_LOWDRIVE);

    //
    // Enable RTC mode.
    //
    MAP_HibernateRTCEnable();

    //
    // Configure the hibernate module counter to 24-hour calendar mode.
    //
    MAP_HibernateCounterMode(HIBERNATE_COUNTER_24HR);
    
    // 
    // Doesn't erase BBRAM nor wake up the MCU from hibernation.
    //
    MAP_HibernateTamperEventsConfig(HIBERNATE_TAMPER_EVENTS_NO_ERASE_HIB_MEM | HIBERNATE_TAMPER_EVENTS_NO_HIB_WAKE);

    //
    // Setup the Tamper IO, this will override any existing IO configuration. 0 == TMPR0 (PM7)
    // Internal weak pull up used, active low
    //
    MAP_HibernateTamperIOEnable(0, HIBERNATE_TAMPER_IO_WPU_ENABLED | HIBERNATE_TAMPER_IO_TRIGGER_LOW);
    
    //
    // Enables the tamper feature.
    //
    MAP_HibernateTamperEnable();
    
    return was_on;
}

void
NmiISR(void)
{
    uint32_t nmi_source = SysCtlNMIStatus();
    switch (nmi_source)
    {
#if HIBERNATION        
        case SYSCTL_NMI_TAMPER:
            DEBUG_MSG("TAMPER NMI\r"); 
            DEBUG_MSG("HIB Tamper Status = 0x%x\r", (HWREG(HIB_TPSTAT) & HIB_TPSTAT_STATE_M) >> 2);
        
            //
            // Clear the source of the NMI. Reset the STATE field of the HIB Tamper Status 
            // register by he STATE field by writing to the TPCLR bit in the HIBTPCTL register.
            //
            HWREG(HIB_TPCTL) |= HIB_TPCTL_TPCLR;
            DEBUG_MSG("HIB Tamper Ctrl = 0x%x\r", (HWREG(HIB_TPCTL) & HIB_TPCTL_TPCLR) >> 4);
            DEBUG_MSG("HIB Tamper Status = 0x%x\r", (HWREG(HIB_TPSTAT) & HIB_TPSTAT_STATE_M) >> 2);
            
            // 
            // Clear the NMIC register bit that corresponds with the NMI source.
            //
            SysCtlNMIClear(nmi_source);
        break;
#endif  /** HIBERNATION */              

        default:
            //
            // Enter an infinite loop.
            //
            for(;;);        
        break;
    }
}

我在终端中看到的输出为:

防篡改 NMI
HIB 篡改状态= 0x2
HIB 篡改控制= 0x0
HIB 篡改状态= 0x2

我可以确认我是否检查 IDE 中的寄存器。 有什么想法吗?

谢谢 HL。

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

    好的,就是意识到了我自己的愚蠢。 我需要解锁篡改寄存器或只使用 HibernateTamperEventsClear ()