$NOMOD51 ;der Modus fuer 8051 wird abgeschaltet $debug $nolist ;es wird kein Listing fuer reg535 erstellt $include(C8051F360.inc) ;die C8051F360-spezifischen Daten $list ;es wird ein Listing erstellt $title (P06_MCWS08.A51) ;------------------------------------------------------------------------ ;Programmbeschreibung ;------------------------------------------------------------------------ ;Programm: ;Grundstellung - irgendwo zwischen auf und ab ;T2 Duty Cycle auf ;T3 Dty Cycle ab ;Die Simulation an P1.1 ist leider nicht zu sehen! ; ;Erstellt am: Freitag, 10. August 2007 09:36:16 ;Programmiert: ; ;Verwendete Einspruenge: keine ; ;Verwendete Unterprogramme: keine ; ; ;Verwendete Register und Variable: ;Registerbank(0) ;R2 ; ;Kommentar: ; ;Aenderungen: ;Geaendert am: Freitag, 10. August 2007 09:36:16 ; ; ;------------------------------------------------------------------------ ;Initialisierungsteil fuer allgemeine Konstanten ;------------------------------------------------------------------------ INC_SERVO EQU 128 CSEG AT 0H ;Legt absolute Codesegmentadresse auf 0h mov PCA0MD,#0 ;Watchdog Timer auf 0 jmp INIT ; ;------------------------------------------------------------------------ ;Interrupt-Vektoren ;------------------------------------------------------------------------ ORG 05Bh clr CF ;Counter Flag quittieren call ISR_PCA ;Interrupt Service Routine aufrufen reti ;------------------------------------------------------------------------ ;Initialisierungsteil fuer On-Chip Peripherie ;------------------------------------------------------------------------ ORG 100H ;Programmstart bei 100H INIT: call Init_Device ;Aufruf der Initialisierung ;------------------------------------------------------------------------ ;Programmschleife ;------------------------------------------------------------------------ ABFRAGE: mov C,P1.1 ;Kopieren des Ausgangsports mov P3.2,C mov P3.3,C mov P3.4,C jmp ABFRAGE ;Warteschleife ISR_PCA: jnb P1.2,DUTY_AUF ;Flanke spaeter jnb P1.3,DUTY_AB ;Flanke frueher ret ;Aus der ISR_PCA DUTY_AUF: mov A,PCA0CPL1 ;Compare P1.1 Low Byte in Akku clr C add A,#INC_SERVO ;Addieren mit Carry mov PCA0CPL1,A ;wieder zurueck mov A,PCA0CPH1 ;HB addc A,#0 ;Carry addieren mov PCA0CPH1,A ;wieder zurueck ret DUTY_AB: mov A,PCA0CPL1 ;Compare P1.1 Low Byte in Akku clr C subb A,#INC_SERVO ;Subtrahieren mit Carry mov PCA0CPL1,A ;wieder zurueck mov A,PCA0CPH1 ;HB subb A,#0 ;Carry subtrahieren mov PCA0CPH1,A ;wieder zurueck ret ;------------------------------------------------------------------------ ; Peripheral specific initialization functions, ; Called from the Init_Device label ;------------------------------------------------------------------------ PCA_Init: mov PCA0CN, #040h mov PCA0MD, #001h mov PCA0CPM1, #0C2h mov PCA0CPM4, #0C2h mov PCA0CPM5, #0C2h mov PCA0CPH1, #080h ret Port_IO_Init: ; P0.0 - Skipped, Push-Pull, Digital ; P0.1 - Skipped, Push-Pull, Digital ; P0.2 - Skipped, Push-Pull, Digital ; P0.3 - Skipped, Push-Pull, Digital ; P0.4 - Skipped, Push-Pull, Digital ; P0.5 - Skipped, Push-Pull, Digital ; P0.6 - Skipped, Push-Pull, Digital ; P0.7 - Skipped, Push-Pull, Digital ; P1.0 - CEX0 (PCA), Push-Pull, Digital ; P1.1 - CEX1 (PCA), Push-Pull, Digital ; P1.2 - CEX2 (PCA), Push-Pull, Digital ; P1.3 - CEX3 (PCA), Push-Pull, Digital ; P1.4 - T0 (Timr0), Push-Pull, Digital ; P1.5 - Skipped, Push-Pull, Digital ; P1.6 - Skipped, Push-Pull, Digital ; P1.7 - Skipped, Push-Pull, Digital ; P2.0 - Skipped, Push-Pull, Digital ; P2.1 - Skipped, Push-Pull, Digital ; P2.2 - Skipped, Push-Pull, Digital ; P2.3 - Skipped, Push-Pull, Digital ; P2.4 - T1 (Timr1), Push-Pull, Digital ; P2.5 - Unassigned, Push-Pull, Digital ; P2.6 - Unassigned, Push-Pull, Digital ; P2.7 - Unassigned, Push-Pull, Digital ; P3.0 - Unassigned, Push-Pull, Digital ; P3.1 - Unassigned, Push-Pull, Digital ; P3.2 - Unassigned, Push-Pull, Digital ; P3.3 - Unassigned, Push-Pull, Digital ; P3.4 - Unassigned, Push-Pull, Digital ; P3.5 - Unassigned, Push-Pull, Digital ; P3.6 - Unassigned, Push-Pull, Digital ; P3.7 - Unassigned, Push-Pull, Digital mov P0MDOUT, #0FFh mov P1MDOUT, #0FFh mov P2MDOUT, #0FFh mov P3MDOUT, #0FFh mov P0SKIP, #0FFh mov P1SKIP, #0E0h mov P2SKIP, #00Fh mov XBR1, #074h ret Oscillator_Init: mov SFRPAGE, CONFIG_PAGE mov OSCICN, #082h mov CLKSEL, #020h ret Interrupts_Init: mov SFRPAGE, CONFIG_PAGE mov EIE1, #010h mov IE, #080h ret ; Initialization function for device, ; Call Init_Device from your main program Init_Device: lcall PCA_Init lcall Port_IO_Init lcall Oscillator_Init lcall Interrupts_Init ret end