Gast
#2190289
Hallo zusammen, ich befasse mich seit ein paar Wochen mit der Programmierung des PIC24FJ64GA004 von Mircochip. Nun stehe ich vor der Aufgabe eine PWM zu erzeugen, die ich über einen Ausgangs-Port ausgeben muss. Da ich mich vorher noch nie damit beschäftigt hatte, habe ich mich im Handbuch über die Initialisierung schlau gemacht und bin dort auf folgende Beispielinitialisierung gestossen: // The following code example will set the Output Compare 1 module // for interrupts on the continuous pulse event and select Timer 2 // as the clock source for the compare time-base. It is assumed // that Timer 2 and Period Register 2 are properly initialized. // Timer 2 will be enabled here. OC1CON = 0x0000; // Turn off Output Compare 1 Module OC1CONbits.OCM = 0x0005; // Load new compare mode to OC1CON OC1R = 0x3000; // Initialize Compare Register1 with 0x3000 OC1RS = 0x3003; // Initialize Secondary Compare Register1 with 0x3003 IPC0bits.OC1IP0 = 1; // Setup Output Compare 1 interrupt for IPC0bits.OC1IP1 = 0; // desired priority level IPC0bits.OC1IP2 = 0; // (this example assigns level 1 priority) IFS0bits.OC1IF = 0; // Clear Output Compare 1 interrupt flag IEC0bits.OC1IE = 1; // Enable Output Compare 1 interrupts T2CONbits.TON = 1; // Start Timer2 with assumed settings als Ausgangsport verwende den Pin RP18 _TRISC2=0; //RP18 output _RP18R=18 //OC1 Das Compilieren funktioniert einwandfrei. Doch beim anschließenden Debug-Versuch mit dem ICD3 bekomme ich nach Klicken auf den RUN-Button sofort die Rückmeldung "TARGET HALTED" und und das Debuggen wird abgebrochen. Meine Frage nun: Was mache ich falsch? Vielen Dank schon mal im voraus für Eure Hilfe! Gruß