[C9] Interrupt

Trong Phuong

Trứng gà
e có viết 1 đoạn code:nháy led P1.6 vs chu kì 0,4s,khi timer đếm đến 50000 thì interrupt:nháy led P1.0. nhưng lúc debug thì chỉ có led P1.0 luôn nháy,led P1.6 im re,huynh đệ xem giúp e ko biết code bị sai chỗ nào,e tìm hoài mà ko ra?!:D
Code:
#include <msp430.h>
 
 
void config_clock()
{
    if (CALBC1_1MHZ==0xFF)                    // If calibration constant erased
          {
            while(1);                              // do not load, trap CPU!!
          }
          DCOCTL = 0;                              // Select lowest DCOx and MODx settings
          BCSCTL1 = CALBC1_1MHZ;                    // Set range
          DCOCTL = CALDCO_1MHZ;
}
void config_timer()
{
    TACCR0 = 50000;
    CCTL0 = CCIE;//interrupt enable
    TACTL = MC_1|ID_3|TASSEL_2|TACLR;//up mode
}
void main(void) {
    WDTCTL = WDTPW | WDTHOLD;    // Stop watchdog timer
    P1DIR = BIT0 + BIT6;
    P1OUT = 0x00;
    config_clock();
    config_timer();
    _BIS_SR(LPM0_bits+GIE);
    while(1)
    {
        P1OUT ^= BIT6;
        _delay_cycles(200000);
    }
 
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void timer_A(void)
{
    P1OUT ^= BIT0;
}
 

MMKC

Thành Viên PIF
Của đệ nè:
Code:
#include <msp430.h>
 
 
void config_clock()
{
    if (CALBC1_1MHZ==0xFF)                    // If calibration constant erased
          {
            while(1);                              // do not load, trap CPU!!
          }
          DCOCTL = 0;                              // Select lowest DCOx and MODx settings
          BCSCTL1 = CALBC1_1MHZ;                    // Set range
          DCOCTL = CALDCO_1MHZ;
}
void config_timer()
{
    TACCR0 = 50000;
    CCTL0 = CCIE;//interrupt enable
    TACTL = MC_1|ID_3|TASSEL_2|TACLR;//up mode
}
void main(void) {
    WDTCTL = WDTPW | WDTHOLD;    // Stop watchdog timer
    P1DIR = BIT0 + BIT6;
    P1OUT = 0x00;
    config_clock();
    config_timer();
    _BIS_SR(GIE);
    while(1)
    {
        P1OUT ^= BIT6;
        _delay_cycles(200000);
    }
 
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void timer_A(void)
{
    P1OUT ^= BIT0;
}
 
Top