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

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

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

2条回答
  •  隐瞒了意图╮
    2021-02-08 16:32

    Note that this information applies to MSPGCC v4.6.3 which pre-dates the Ti/Redhat/SOMNIUM port of MSPGCC which is now distributed with code composer studio.

    Thanks go to Peter Bigot of the Mspgcc-users mailing list for this answer.

    There are two possibilities:

    A. Use Code composer studio style syntax (has the added benefit of being portable to CCS):

    #pragma vector=TIMER0_A0_VECTOR    
    __interrupt void
    ta0cc0_isr (void)
    

    (Note that this was introduced somewhere around version 20120406 of Mspgcc).

    B. Use native gcc syntax:

    static void
    __attribute__((__interrupt__(TIMER0_A0_VECTOR)))
    isr_cc0_TA0 (void)
    

    C. Name the function correctly so that it is included into the vector table (useful for ASM functions).

    The interrupt attribute causes the function to be named __isr_X where X is the word offset of the interrupt from the vector table start (equal to the value of the interrupt attribute's parameter divided by 2).

    These __isr_X symbols are used to initialize the vector table in crt0ivtbl.o.

提交回复
热议问题