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.

BASIC TIMER中断不知道什么原因进不去

Other Parts Discussed in Thread: MSP430F4152

上电后,ACLK默认外部低速晶振,匹配电容选的是10pF,单片机选用的是MSP430F4152,IAR使用的是5.30的。

会不会和头文件有关?

这是程序

u8 i;
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer to prevent time out reset
FLL_CTL0 |=XCAP11PF; //设置匹配电容为12Pf

do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0x47FF; i > 0; i--); // Time for flag to set
}
while (IFG1 & OFIFG); // OSCFault flag still set?

//开basictime中断
//Init_Clk();
Init_Port();
InitState();
Init_Lcd();

BTCTL |= BT_ADLY_16;//+ BT_fLCD_512; //设置basictimer 8ms中断,LCD的刷新频率为512HZ
IE2 |= BTIE;
__bis_SR_register(GIE);
while (1) // repeat forever
{
DisBlcd();

}

}

  • //******************************************************************************
    //  MSP430x41x2 Demo - Basic Timer, Toggle P5.1 Inside ISR, 32kHz ACLK
    //
    //  Description: Toggles P5.1 by xor'ing P5.1 inside of a basic timer ISR.
    //  ACLK provides the basic timer clock source. LED toggles every 125ms.
    //  ACLK = LFXT1 = 32768Hz, MCLK = SMCLK = default DCO = 32 x ACLK = 1048576Hz
    //  //* An external watch crystal between XIN & XOUT is required for ACLK *//
    //
    //               MSP430x41x2
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 | 32kHz
    //          --|RST          XOUT|-
    //            |                 |
    //            |             P5.1|-->LED
    //
    //  P. Thanigai
    //  Texas Instruments Inc.
    //  January 2009
    //  Built with CCE Version: 3.1 and IAR Embedded Workbench Version: 4.11
    //*****************************************************************************
    #include <msp430.h>
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      FLL_CTL0 |= XCAP11PF;                     // Set load cap for 32k xtal
      P5DIR |= 0x02;                            // Set P5.1 as output
      BTCTL = BTDIV + BT_fCLK2_DIV16;           // ACLK/(256*16)
      IE2 |= BTIE;                              // Enable BT interrupt
    
      __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3, enable interrupts
    }
    
    // Basic Timer Interrupt Service Routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=BASICTIMER_VECTOR
    __interrupt void basic_timer_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(BASICTIMER_VECTOR))) basic_timer_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      P5OUT ^= 0x02;                            // Toggle P5.1
    }
  • 请问

    BT_fCLK2_DIV16是做什么用的呢?BTDIV不是已经是256分频了吗?
    我把这个加上后,能用了。但是我在把它注释掉也能用了!!!请问你这是什么原因?谢谢
  • BT_fCLK2_DIV16的宏定义:


    #define BT_fCLK2_DIV16 (BTIP1+BTIP0) /* fINT = fCLK2:16 */