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.

[参考译文] MSP430FR6047:__ bic_SR_register_on_exit 需要汇编代码

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1325751/msp430fr6047-__bic_sr_register_on_exit-assembly-code-needed

器件型号:MSP430FR6047

您好!

我必须将这一呼吁抽象出来、  

__ BIC_SR_REGISTER_ON_EXIT  
我的问题是:我从一个中断例程中调用这个例程、但是在一个子例程中。 遗憾的是、编译器无法识别这一点、因此我收到一个编译器错误。  
有可能获得这个例程的汇编代码吗?

此致

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

    也许可以用一个位代码来了解我想要实现的目标:

    template <typename Derived>
    class ITest
    {
    
      public:
      static constexpr inline void wakeup()
      {
        Derived::wakeupImpl();
      }
    };
    
    class Test : public ITest<Test>
    {
      protected:
    
      friend class ITest<Test>;
      static constexpr inline void wakeupImpl()
      {
        __bic_SR_register_on_exit(LPM3_bits);
      }
    
    };
    
    void __attribute__((interrupt(USCI_A0_VECTOR))) USCI_A0_ISR(void)
    {
      WakeState wakeState;
      MyUart::intByteReceived(wakeState);
    
      if(wakeState == WakeState::Wakeup)
      {
        Test::wakeup();
      }
    }

    导致此错误:  

    错误:MSP430内置函数仅在中断处理程序内部工作
    [构建]   84 |  ___ bic_SR_register_on_exit (LPM3_BITS);
  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    这必须在 ISR 中使用、因为编译器必须准确知道 SR 寄存器在栈上的保存位置。 它知道在 ISR 中、但不在 ISR 调用的函数中。

    鉴于其显示"on_exit"、我假设这通常但并非总是延迟到 RTI 指令之前。

    使用的指令是"BIC #LMP3_BITS、OFFSET (SP)"。 当然,您可以使用 asm ()语句插入该语句,并使用您确定要使用的偏移量。 今天。 当然、当你明天更新编译器时、这可能会中断。 或更改优化级别。

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

    static __attribute__((always_inline)) inline void wakeUp()

    感谢您的回答。 我的解决方案是、保持抽象、现在是强制内联。 工作原理。