想利用TimerA的interrupt使LED閃爍

47 views
Skip to first unread message

Jed Kuo

unread,
Feb 1, 2016, 10:48:11 AM2/1/16
to [LaunchPad互動裝置] TI MSP430 LaunchPad 使用者討論區
各位朋友大家好, 最近剛接觸MSP430, 自己試著寫了一個利用TimerA的interrupt來讓LED閃爍的程式, 但不知道為什麼連編譯都無法成功, 不知道是犯了什麼錯誤, 希望看到問題的朋友可以跟我說一聲, 非常感謝!!

#include <msp430.h>
#define LED1 BIT0

void main(void) {
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
    P1OUT = ~LED1;
    P1DIR = LED1;

    TACCR0 = 49999;
    TACTL = MC_1|ID_3|TASSEL_2|TACLR;

    _BIS_SR(GIE);

    while (1) {}
}

#pragma vector = TIMERA0_VECTOR
_ _interrupt void TIMERA0_ISR ( void ) // Flag cleared automatically
{
P1OUT ˆ= LED1;
}

Wang Taiyuan

unread,
Feb 1, 2016, 7:43:36 PM2/1/16
to msp430lau...@googlegroups.com
請問出現何錯誤訊息呢?

--
--
您收到此郵件,是因為您訂閱了 Google 網上論壇的「[玩USB互動裝置] TI
MSP430 LaunchPad 使用者討論區」群組。
如要在此群組張貼留言,請寄電子郵件至 msp430lau...@googlegroups.com
如要取消訂閱此群組,請寄電子郵件至
msp430launchpad...@googlegroups.com
如需更多選項,請造訪此群
組:http://groups.google.com/group/msp430launchpaddiy?hl=zh-TW?hl=zh-TW

---
這是 Google 網上論壇針對「[LaunchPad互動裝置] TI MSP430 LaunchPad 使用者討論區」群組發送的訂閱通知郵件。
如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到 msp430launchpad...@googlegroups.com
如需更多選項,請前往:https://groups.google.com/d/optout

Jed Kuo

unread,
Feb 2, 2016, 10:37:26 AM2/2/16
to [LaunchPad互動裝置] TI MSP430 LaunchPad 使用者討論區
版主你好:

錯誤訊息為: pragma vector = accepts numeric arguments or "unused_interrupts" but not TIMERA0_VECTOR

我想問題可能是因為不同的CPU所支援的interrupt vector的名稱不同, 2553這顆可能不能用 TIMERA0_VECTOR , 但目前還不知道該如何修改. ( 有試著改為 TIMER(X)_A(Y)_VECTOR X, Y=0 or 1, 但好像還是不行, 不太確定要怎麼查究竟要用哪個?) 

#pragma vector = TIMERA0_VECTOR
__interrupt void TIMERA0_ISR ( void ) // Flag cleared automatically
{
P1OUT ˆ= LED1;
}

謝謝你的回覆!


版主於 2016年2月2日星期二 UTC+8上午8時43分36秒寫道:
請問出現何錯誤訊息呢?

2016-02-01 23:48 GMT+08:00 Jed Kuo <kuo...@gmail.com>:
各位朋友大家好, 最近剛接觸MSP430, 自己試著寫了一個利用TimerA的interrupt來讓LED閃爍的程式, 但不知道為什麼連編譯都無法成功, 不知道是犯了什麼錯誤, 希望看到問題的朋友可以跟我說一聲, 非常感謝!!

#include <msp430.h>
#define LED1 BIT0

void main(void) {
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
    P1OUT = ~LED1;
    P1DIR = LED1;

    TACCR0 = 49999;
    TACTL = MC_1|ID_3|TASSEL_2|TACLR;

    _BIS_SR(GIE);

    while (1) {}
}

#pragma vector = TIMERA0_VECTOR
_ _interrupt void TIMERA0_ISR ( void ) // Flag cleared automatically
{
P1OUT ˆ= LED1;
}

--
--
您收到此郵件,是因為您訂閱了 Google 網上論壇的「[玩USB互動裝置] TI
MSP430 LaunchPad 使用者討論區」群組。
如要在此群組張貼留言,請寄電子郵件至 msp430lau...@googlegroups.com
如要取消訂閱此群組,請寄電子郵件至

如需更多選項,請造訪此群
組:http://groups.google.com/group/msp430launchpaddiy?hl=zh-TW?hl=zh-TW

---
這是 Google 網上論壇針對「[LaunchPad互動裝置] TI MSP430 LaunchPad 使用者討論區」群組發送的訂閱通知郵件。
如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到 msp430launchpaddiy+unsub...@googlegroups.com
如需更多選項,請前往:https://groups.google.com/d/optout

Jed Kuo

unread,
Feb 3, 2016, 11:46:47 AM2/3/16
to [LaunchPad互動裝置] TI MSP430 LaunchPad 使用者討論區
已成功! 給大家做個參考 ^^

#include <msp430.h>
#define LED1 BIT0

void main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
CCTL0 = CCIE;   // CCR0 interrupt enabled
P1OUT = ~LED1;
P1DIR = LED1;

TACCR0 = 49999;
TACTL = MC_1|ID_3|TASSEL_2|TACLR;
_BIS_SR(GIE);
while (1) {}
}

#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer_A (void) {
P1OUT ^= LED1;
}

Jed Kuo於 2016年2月2日星期二 UTC+8下午11時37分26秒寫道:
Reply all
Reply to author
Forward
0 new messages