Hallo Ich sollte "nur" eine Pulsweitenmodulation programmieren. Doch mit den angegebenen Schritten im Datenblatt komme ich nicht ganz klar. 11.3.7 SETUP FOR PWM OPERATION The following steps should be taken when configuring the CCP module for PWM operation: 1. Disable the PWM pin (CCP1) output driver by setting the associated TRIS bit. 2. Set the PWM period by loading the PR2 register. 3. Configure the CCP module for the PWM mode by loading the CCP1CON register with the appropriate values. 4. Set the PWM duty cycle by loading the CCPR1L register and DC1B<1:0> bits of the CCP1CON register. 5. Configure and start Timer2: • Clear the TMR2IF interrupt flag bit of the PIR1 register. • Set the Timer2 prescale value by loading the T2CKPS bits of the T2CON register. • Enable Timer2 by setting the TMR2ON bit of the T2CON register. 6. Enable PWM output after a new PWM cycle has started: • Wait until Timer2 overflows (TMR2IF bit of the PIR1 register is set). • Enable the CCP1 pin output driver by clearing the associated TRIS bit. Frage zu Punkt 1: Im Datenblatt (PIC16F690) steht, man sollte CCP1 ausschalten, doch im C Compiler Reference Manual steht, dass man für ein Rechteck-PWM Signal den Befehl : setup_ccp1(CCP_PWM) eintippen muss. Ich hoffe, ihr könnt mir helfen. Und ich muss schon sagen, dass ich noch nicht ganz der Profi im programmieren bin. LG
Hallo, ich beschäftige mich auch im Moment mit PWM. Es ist eigentlich gang einfach: - Der Pin CCP1 muss auf "0" geschaltet werden, damit er als Ausgang deklariert wird. - In das Register PR2 lädst du den Wert, der mit dem Timer (meist Timer 2) verglichen werden soll - CCP1CON, das sind deine 2 zusätzlichen LSB um auf 10 Bit zu kommen - Unter Punkt 4 stellst du den HIGH-Pegel deiner Periode ein - Unter 5 bestimmst du wie schnell dein Zähler zählen soll, Achtung du musst den Zähler extra einschalten Gruß Kay
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.