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.

[参考译文] LP-MSPM0G3507:SysTicks 工作十分出色

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1327709/lp-mspm0g3507-systicks-works-exceptionally

器件型号:LP-MSPM0G3507
主题中讨论的其他器件:MSPM0G3507

大家好:

我不熟悉这款 EVB 和 MCU。 我想创建一个运行1ms 周期的 SysTick 并触发回调函数。 这就是问题所在。  

我可以启用 SysTick 并在闭环中获取该值。 但在 CCS syscfg 中、如果我选中"启用 SysTick 中断"。 程序启动后、系统将在一段时间内崩溃。 (系统启动后,我的程序会打印出一个字符串。 在这种情况下,字符串无法完全打印出来,系统崩溃进入 hard_fault()。 中断好像被损毁了。 有什么建议吗? 如何注册回调函数? 谢谢~~

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

    嗨、 

    请尝试一下 SDK 中的演示代码: systick_periodic_timer_LP_MSPM0G3507_nortos_ticlang

    它将在每个 SysTick 中断(500ms)期间切换 LED。

    此致、

    赫利克

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

    对我来说很好。

    // Systick stuff
    volatile uint32_t Tick;
    
    uint32_t GetTicks() {
      uint32_t tmp;
    
      DL_SYSTICK_disableInterrupt();
      tmp = Tick;
      DL_SYSTICK_enableInterrupt();
      return tmp;
    }
    
    void SysTick_Handler(void) { Tick++; }
    
    void Delay(uint32_t delaytime) {
      uint32_t start = GetTicks();
    
      while ((GetTicks() - start) < delaytime) {
        delay_cycles(10000); // nothing better to do...
      }
    }

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

    尊敬的 

    我将重新检查示例、感谢您的建议。

    尊敬的

    在您的示例中"Sys Tick_Handler ()"似乎是默认的中断回调函数。 "谢谢,我不知道我能在另一个地方使用它。

    顺便说一下、我已经解决了这个问题。 我对 DL_Interrupt_registerInterrupt()的第一个参数是错误的。 我在开始时使用了 dl_interrupt.h 中的定义。 这是不对的。 我一次又一次地检查了 RTM。 最后、我使用了"mspm0g350x.h"中的定义。 然后一切正常。

    int main(void)
    {
        SYSCFG_DL_init();
    
        DL_Interrupt_registerInterrupt(SysTick_IRQn, SysTick_CB);
        DL_SYSTICK_enableInterrupt();
        DL_SYSTICK_enable();
    
        SWTimer_Create();
        CLI_Init();
    
        uart_printf(CYAN"\r\nFIDM Start\r\n"NONE);
    
        SWTimer_UserSetRepeat(loop_1s, 1000U, 0, false);
    
        while (true) {
            SCLI_Run();
        }
    }

    感谢您、两位

    Jacky