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.

【MSP430F5529的定时器中断写法】

Other Parts Discussed in Thread: MSP430F5529

我在编写5529定时器的代码的时候,一直对这两句话的理解存在一些疑问

#pragma vector = TIMER1_A1_VECTOR
__interrupt void TIMER1_A1_ISR(void)

,这两句话有很多种写法,让我摸不着头脑,有的是vector = TIMERB1_VECTOR,A1那个位置没有了,而且TIMER1变成了TIMERB1,多了一个B

有的又是这样的

#pragma vector = TIMER1_A1_VECTOR
__interrupt void TIMER0_A1_ISR(void)

上面是TIMER1,下面是TIMER0,两个不一样了,我以前写的是时候都是参考mspware里面的例程,但是我想自己写的时候,却不知道这个位置应该怎么写,这个位置有什么规则,应该怎样写才是正确的,

求教?

 

  • __interrupt 用来定义一个中断函数。用#pragma vector来提供中断函数的入口地址

    具体您可以看一下 msp430f5529.h

    /************************************************************
    * Interrupt Vectors (offset from 0xFF80)
    ************************************************************/
    
    #pragma diag_suppress 1107
    #define VECTOR_NAME(name)             name##_ptr
    #define EMIT_PRAGMA(x)                _Pragma(#x)
    #define CREATE_VECTOR(name)           void * const VECTOR_NAME(name) = (void *)(long)&name
    #define PLACE_VECTOR(vector,section)  EMIT_PRAGMA(DATA_SECTION(vector,section))
    #define PLACE_INTERRUPT(func)         EMIT_PRAGMA(CODE_SECTION(func,".text:_isr"))
    #define ISR_VECTOR(func,offset)       CREATE_VECTOR(func); \
                                          PLACE_VECTOR(VECTOR_NAME(func), offset) \
                                          PLACE_INTERRUPT(func)
    
    
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define RTC_VECTOR              ".int41"                     /* 0xFFD2 RTC */
    #else
    #define RTC_VECTOR              (41 * 1u)                    /* 0xFFD2 RTC */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define PORT2_VECTOR            ".int42"                     /* 0xFFD4 Port 2 */
    #else
    #define PORT2_VECTOR            (42 * 1u)                    /* 0xFFD4 Port 2 */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define TIMER2_A1_VECTOR        ".int43"                     /* 0xFFD6 Timer2_A5 CC1-4, TA */
    #else
    #define TIMER2_A1_VECTOR        (43 * 1u)                    /* 0xFFD6 Timer2_A5 CC1-4, TA */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define TIMER2_A0_VECTOR        ".int44"                     /* 0xFFD8 Timer2_A5 CC0 */
    #else
    #define TIMER2_A0_VECTOR        (44 * 1u)                    /* 0xFFD8 Timer2_A5 CC0 */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define USCI_B1_VECTOR          ".int45"                     /* 0xFFDA USCI B1 Receive/Transmit */
    #else
    #define USCI_B1_VECTOR          (45 * 1u)                    /* 0xFFDA USCI B1 Receive/Transmit */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define USCI_A1_VECTOR          ".int46"                     /* 0xFFDC USCI A1 Receive/Transmit */
    #else
    #define USCI_A1_VECTOR          (46 * 1u)                    /* 0xFFDC USCI A1 Receive/Transmit */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define PORT1_VECTOR            ".int47"                     /* 0xFFDE Port 1 */
    #else
    #define PORT1_VECTOR            (47 * 1u)                    /* 0xFFDE Port 1 */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define TIMER1_A1_VECTOR        ".int48"                     /* 0xFFE0 Timer1_A3 CC1-2, TA1 */
    #else
    #define TIMER1_A1_VECTOR        (48 * 1u)                    /* 0xFFE0 Timer1_A3 CC1-2, TA1 */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define TIMER1_A0_VECTOR        ".int49"                     /* 0xFFE2 Timer1_A3 CC0 */
    #else
    #define TIMER1_A0_VECTOR        (49 * 1u)                    /* 0xFFE2 Timer1_A3 CC0 */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define DMA_VECTOR              ".int50"                     /* 0xFFE4 DMA */
    #else
    #define DMA_VECTOR              (50 * 1u)                    /* 0xFFE4 DMA */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define USB_UBM_VECTOR          ".int51"                     /* 0xFFE6 USB Timer / cable event / USB reset */
    #else
    #define USB_UBM_VECTOR          (51 * 1u)                    /* 0xFFE6 USB Timer / cable event / USB reset */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define TIMER0_A1_VECTOR        ".int52"                     /* 0xFFE8 Timer0_A5 CC1-4, TA */
    #else
    #define TIMER0_A1_VECTOR        (52 * 1u)                    /* 0xFFE8 Timer0_A5 CC1-4, TA */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define TIMER0_A0_VECTOR        ".int53"                     /* 0xFFEA Timer0_A5 CC0 */
    #else
    #define TIMER0_A0_VECTOR        (53 * 1u)                    /* 0xFFEA Timer0_A5 CC0 */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define ADC12_VECTOR            ".int54"                     /* 0xFFEC ADC */
    #else
    #define ADC12_VECTOR            (54 * 1u)                    /* 0xFFEC ADC */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define USCI_B0_VECTOR          ".int55"                     /* 0xFFEE USCI B0 Receive/Transmit */
    #else
    #define USCI_B0_VECTOR          (55 * 1u)                    /* 0xFFEE USCI B0 Receive/Transmit */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define USCI_A0_VECTOR          ".int56"                     /* 0xFFF0 USCI A0 Receive/Transmit */
    #else
    #define USCI_A0_VECTOR          (56 * 1u)                    /* 0xFFF0 USCI A0 Receive/Transmit */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define WDT_VECTOR              ".int57"                     /* 0xFFF2 Watchdog Timer */
    #else
    #define WDT_VECTOR              (57 * 1u)                    /* 0xFFF2 Watchdog Timer */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define TIMER0_B1_VECTOR        ".int58"                     /* 0xFFF4 Timer0_B7 CC1-6, TB */
    #else
    #define TIMER0_B1_VECTOR        (58 * 1u)                    /* 0xFFF4 Timer0_B7 CC1-6, TB */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define TIMER0_B0_VECTOR        ".int59"                     /* 0xFFF6 Timer0_B7 CC0 */
    #else
    #define TIMER0_B0_VECTOR        (59 * 1u)                    /* 0xFFF6 Timer0_B7 CC0 */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define COMP_B_VECTOR           ".int60"                     /* 0xFFF8 Comparator B */
    #else
    #define COMP_B_VECTOR           (60 * 1u)                    /* 0xFFF8 Comparator B */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define UNMI_VECTOR             ".int61"                     /* 0xFFFA User Non-maskable */
    #else
    #define UNMI_VECTOR             (61 * 1u)                    /* 0xFFFA User Non-maskable */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define SYSNMI_VECTOR           ".int62"                     /* 0xFFFC System Non-maskable */
    #else
    #define SYSNMI_VECTOR           (62 * 1u)                    /* 0xFFFC System Non-maskable */
    #endif
    #ifdef __ASM_HEADER__ /* Begin #defines for assembler */
    #define RESET_VECTOR            ".reset"                     /* 0xFFFE Reset [Highest Priority] */
    #else
    #define RESET_VECTOR            (63 * 1u)                    /* 0xFFFE Reset [Highest Priority] */
    #endif

  • 谢谢您的指点,我还有一点想问的,TIMER2_A1_VECTOR,这个变量指向哪里,TIMER2和A1代表的是什么以意思,定时器A的通道2的意思吗,还是另外的意思?那么这几个呢?TIMER0_A0_VECTOR 和 TIMERB1_VECTOR,里面出现的这些标识代表的是什么意思,或者说在哪里能找到这些标识的解释?
  • 有必要说明一下5529的定时器

    MSP430F5529共有两类共4个定时器,分别是Timer_A定时器3个和Timer_B定时器1个,按照每个寄存器配备的捕获/比较器的个数分别命名为Timer0_A(内有5个捕获比较器)、Timer1_A(3个)、Timer2_A(3个)、Timer0_B(7个)。

    然后请您对照一下上面msp430f5529.h内说明

  • 非常感谢你的回答,我懂了,谢谢!
  • 很高兴能帮到您!