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.

Timer問題

Other Parts Discussed in Thread: CC430F6137

我最近在研究 CC430F6137的Timer的功能

抓了網路上的範例

我發現到 當程式進入了中斷副程式之後

程式不會再跑回主程式

請問到底是哪裡出了錯誤?

感謝 懇請賜教 

#include "cc430x613x.h"

void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= 0x01; // P1.0 output
TA1CCTL0 = CCIE; // CCR0 interrupt enabled
TA1CCR0 = 50000;
TA1CTL = TASSEL_2 + MC_2 + TACLR; // SMCLK, contmode, clear TAR

__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, enable interrupts
__no_operation(); // For debugger

}


// Timer A0 interrupt service routine
#pragma vector=TIMER1_A0_VECTOR
__interrupt void TIMER1_A0_ISR(void)
{
P1OUT ^= 0x01; // Toggle P1.0

}

  • 中断服务程序中没有退出LMP0;再就是主程序中没有循环

  • 請問要如何退出中斷LMP0?

  • 如果看到P1.0的LED灯会闪烁就表明退出中断。也可以用示波器测量P1.0 端口的电平变化。那个程序在仿真器调试时可能确实看不出光标停留在那个位置。

  • 各种低功耗模式退出,建议楼主买本书看一下。

    #define LPM0 _bis_SR_register(LPM0_bits) /* Enter Low Power Mode 0 */
    #define LPM0_EXIT _bic_SR_register_on_exit(LPM0_bits) /* Exit Low Power Mode 0 */
    #define LPM1 _bis_SR_register(LPM1_bits) /* Enter Low Power Mode 1 */
    #define LPM1_EXIT _bic_SR_register_on_exit(LPM1_bits) /* Exit Low Power Mode 1 */
    #define LPM2 _bis_SR_register(LPM2_bits) /* Enter Low Power Mode 2 */
    #define LPM2_EXIT _bic_SR_register_on_exit(LPM2_bits) /* Exit Low Power Mode 2 */
    #define LPM3 _bis_SR_register(LPM3_bits) /* Enter Low Power Mode 3 */
    #define LPM3_EXIT _bic_SR_register_on_exit(LPM3_bits) /* Exit Low Power Mode 3 */
    #define LPM4 _bis_SR_register(LPM4_bits) /* Enter Low Power Mode 4 */
    #define LPM4_EXIT _bic_SR_register_on_exit(LPM4_bits) /* Exit Low Power Mode 4 */

  • 感謝Billy的幫忙 解決了我的問題 謝謝 

  • 好 我們會試試看 謝謝