Gast
#2434996
Hallo zusammen! mein folgendes µC Programm woll einfach nicht funktionieren, wo liegt mein fehler? ich will ein LED , das an P1.0 hängt mit hilfe eines timer interrupts toggeln. mfg tom //author: Thomas Thurner #include <msp430f2012.h> #include "intrinsics.h" unsigned int c1,c2,c3,c4,c5,start; void config_clock(void); void config_io(void); void config_timerA2(void); void init(void); void config_clock(void) { if (CALBC1_16MHZ ==0xFF || CALDCO_16MHZ == 0xFF) //test if information memory (EEPROM) has stored calibration data { while(1); // TRAP, stay in loop } BCSCTL1 = XT2OFF + CALBC1_16MHZ; // set range to 16MHz DCOCTL = CALDCO_16MHZ; // set DCO step + modulation to 1MHz BCSCTL2 = SELM_0 + DIVM_0 + DIVS_3; // MCLK = DCO/1 and SMCLK = DCO/1 //BCSCTL3 = LFXT1S_2; // LFXT1 = VLO ONLY at MSP430x21x1 devices (!) IFG1 &= ~OFIFG; // Clear OSCFault flag } void config_timerA2(void) { CCTL0 = CCIE; // CCR0 interrupt enabled TACTL = TASSEL_1 + MC_1; // MCLK, upmode TACCR0 = 0x2F; // init value for timer periode } void config_io(void) { P1DIR = ~0x0C; P1OUT = 0x0C; P1SEL = 0x00; P1REN = 0x08; P1IE = 0x0C; // enable interrupts at port P1.3 P1IES = 0x0C; // P1.0 interrupt if HI-to-LO edge detected P1IFG = 0x00; // clear all P1 interrupt flags } void init(void) { start=0; c1=0; c2=0; c3=0; c4=0; c5=0; } // MAIN ************************************************************************ void main( void ) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer to prevent time out reset config_clock(); config_timerA2(); config_io(); init(); __enable_interrupt(); while(1) { } } // MAIN END ******************************************************************** // Timer_A2 interrupt service routine ******************* #pragma vector=TIMERA0_VECTOR __interrupt void timer_A(void) { c1++; if(c1>=16000) { c2++; c1=0; } if(c2>=21) { P1OUT^=0x01; c2=0; } } // PORT1 interrupt service routine ******************* #pragma vector=PORT1_VECTOR __interrupt void Port_1(void) { }