Part Number: MSP430FR2355 Hello everybody, I´m currentlich trying to run the following code (I believe the problem is my interrupt, somehow? I think the interrupt is not activated or something like that?): #define HALBTON_TIEFER(wert) (unsigned int)((wert*69432L)>>16) #define HALBTON_HOEHER(wert) (unsigned int)((wert*61858L)>>16) #define a1 2400 #define h1 HALBTON_HOEHER(HALBTON_HOEHER(a1)) #define c2 HALBTON_HOEHER(h1) #define g1 HALBTON_TIEFER(HALBTON_TIEFER(a1)) #define f1 HALBTON_TIEFER(HALBTON_TIEFER(g1)) #define e1 HALBTON_TIEFER(f1) #define d1 HALBTON_TIEFER(HALBTON_TIEFER(e1)) #define c1 HALBTON_TIEFER(HALBTON_TIEFER(d1)) #define TEMPO 80 #define CNTS_PER_ACHTEL (1966080L>>1)/TEMPO typedef enum Enum_Ton {C1= c1,D1 = d1,E1 = e1,F1 = f1,G1 = g1,A1 = a1,H1 = h1,C2 = c2} tEnum_Ton; typedef enum Enum_Dauer {t8=1,t4=2,t2=4,t1=8} tEnum_Dauer; typedef struct tsListe { volatile tEnum_Ton eTon; volatile tEnum_Dauer eDauer; }tsListe; // list with tones and sound length const volatile tsListe tlist[] = { {C1,t8},{D1,t8},{E1,t8},{F1,t8},{G1,t4},{G1,t4},{A1,t8},{A1,t8},{A1,t8},{A1,t8},{G1,t2},{A1,t8}, {A1,t8},{A1,t8},{A1,t8},{G1,t2},{F1,t8},{F1,t8},{F1,t8},{F1,t8},{E1,t4},{E1,t4},{G1,t8},{G1,t8}, {G1,t8},{G1,t8},{C1,t2} }; volatile uint16_t len = 26; volatile uint16_t uiAchtelCnt = 0; volatile uint16_t uiNoteIdx = 0; int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop WDT P1DIR |= BIT6; // P1.6 output P1SEL1 |= BIT6; // P1.6 options select // Disable the GPIO power-on default high-impedance mode to activate // previously configured port settings PM5CTL0 &= ~LOCKLPM5; // f(DCO) = 1048 kHz // f(DCO)/f(440) = 2382 steps per period volatile const uint16_t freq_steps = 2382; TB0CCR0 = freq_steps; // PWM Period TB0CCTL1 = OUTMOD_3; // CCR1 set/reset // Set duty cycle to 50% TB0CCR1 = TB0CCR0>>1; // CCR1 PWM duty cycle //TBCCTL1 = CCIE; TB0CCTL2 = OUTMOD_3; // CCR2 set/reset TB0CCR2 = 400; // CCR2 PWM duty cycle TBCCTL2 = CCIE; // CCR2 interrupt timer TB0CTL = TBSSEL__ACLK | MC__UP | TBCLR; // ACLK, up mode, clear TBR __bis_SR_register(LPM0_bits+GIE); // Enter LPM0 enable Interrupt flag __no_operation(); // For debugger } // Interrupt Vector #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__) #pragma vector=TIMER1_B0_VECTOR _ #pragma vector = TIMER1_B1_VECTOR _interrupt void Timer1_CCR0_ISR(void) #endif { if (uiAchtelCnt == 0) { if (uiNoteIdx == len) { uiNoteIdx = 0; } else if (uiNoteIdx == 0){ // Do nothing } else{ uiNoteIdx++; } puts("%d",uiNoteIdx); tsListe currentTon = tlist[uiNoteIdx]; TB0CCR0 = currentTon.eTon; TB0CCR1 = TB0CCR0>>1; uiAchtelCnt = currentTon.eDauer; uiAchtelCnt--; //__delay_cycles(400); } else { uiAchtelCnt--; //__delay_cycles(400); } } I´m totally new with embedded programming, and especially I do not understand interrupts very well. Can somebody help me out here? :) Thanks a lot, greetings Valeria
↧