How to declare an interrupt handler (ISR) in Mspgcc?

前端 未结 2 1383
北海茫月
北海茫月 2021-02-08 16:05

What is the preferred method of declaring an interrupt handler in mspgcc?

2条回答
  •  有刺的猬
    2021-02-08 16:41

    Just to clarify, because this is an early Google result.

    __attribute__((__interrupt__(TIMER0_A0_VECTOR)))
    void __isr_5(void)
    {
            ...
    }
    

    Current GCC still (I believe this is what arvindpdmn commented about) raises an error, when using above syntax.

    internal compiler error: in msp430_attr, at config/msp430/msp430.c:1835
     {
     ^
    

    An issue was raised for this after a report of this in the TI E2E community, but said issue is still in its "Planned" state and it is unclear who the tracker even belongs to. (You can access the issue via the thread in above link.)

    Looking at the code, the error is apparently raised, because the only attribute that may have arguments, is the interrupt attribute.

    In fact, compilation works fine, if the leading and following underscores are omitted.

    This right here is the correct syntax!

    __attribute__((interrupt(TIMER0_A0_VECTOR)))
    void name_does_not_matter(void)
    {
            ...
    }
    

    And in fact, this attribute is documented in the official GNU GCC documentation. In retrospect, it is rather unclear where the underscores came from in the first place. So, basically, the only problem here is that the error message is so uninformative.

提交回复
热议问题