$NOMOD51 ;der Modus fuer 8051 wird abgeschaltet $debug $nolist ;es wird kein Listing fuer reg535 erstellt $include(C8051F340.inc) ;die C8051F340-spezifischen Daten $list ;es wird ein Listing erstellt $title (DREI_STELLUNGEN.A51) ;------------------------------------------------------------------------ ;Programmbeschreibung ;------------------------------------------------------------------------ ;Programm: DREI-STELLUNGEN ;faehrt drei Stellungen an: ;Ruhestellung 150° ; 150° ~ F531h ;T3--> 90° ~ EF23h ca. 1s warten danach auf ; 30° ~ E8A7h ca. 1s warten danach auf Ruhestellung ; 46 * 21,45ms ~ 1s ; ~ 2s ;Erstellt am: Montag, 28. Juni 2010 09:09:04 ;Programmiert: Juergen Walter ; ;Verwendete Einspruenge: keine ; ;Verwendete Unterprogramme: keine ; ; ;Verwendete Register und Variable: ;Registerbank(0) ;R2 ; ;Kommentar: ; ;Aenderungen: ;Geaendert am: Montag, 28. Juni 2010 09:09:04 ; ; ;------------------------------------------------------------------------ ;Initialisierungsteil fuer allgemeine Konstanten ;------------------------------------------------------------------------ SEKUNDEN EQU 46 ;Wartezeit 1s ueber PCA Interrupts STLG_01L EQU 31h ;Stellung 01 Low-Byte STLG_01H EQU 0F5h ;Stellung 01 High-Byte STLG_02L EQU 23h ;Stellung 02 Low-Byte STLG_02H EQU 0EFh ;Stellung 02 High-Byte STLG_03L EQU 0A7h ;Stellung 03 Low-Byte STLG_03H EQU 0E8h ;Stellung 03 High-Byte CSEG AT 0H ;Legt absolute Codesegmentadresse auf 0h jmp INIT ; ;------------------------------------------------------------------------ ;Interrupt-Vektoren ;------------------------------------------------------------------------ ORG 05Bh clr CF ; Interrupt erkannt call ISR_PCA0 ; PCA Interrupt Servie Routine reti ;------------------------------------------------------------------------ ;Initialisierungsteil fuer On-Chip Peripherie ;------------------------------------------------------------------------ ORG 100H ;Programmstart bei 100H INIT: call Init_Device ;Aufruf zur Initialisierung der Controller Funktionen ;------------------------------------------------------------------------ ;Programmschleife ;------------------------------------------------------------------------ ABFRAGE: jnb P1.3,DREI_STELLUNGEN ; T1--> Drei Stellungen jmp ABFRAGE DREI_STELLUNGEN: mov PCA0CPL0,#STLG_02L ;Stellung 2 mov PCA0CPH0,#STLG_02H call WARTEN_nS mov PCA0CPL0,#STLG_03L ;Stellung 3 mov PCA0CPH0,#STLG_03H call WARTEN_nS mov PCA0CPL0,#STLG_01L ;Stellung 1 mov PCA0CPH0,#STLG_01H jmp ABFRAGE WARTEN_nS: clr F0 ;F0 =0 Sekunde nicht vorbei mov R2,#SEKUNDEN ;R2 laden mov EIE1,#010h ;PCA0-Interrupts ermoeglichen jnb F0,$ ;warten bis F0=1 --> ausserhalb der Interrupt ;Service Routine - weiterer Interrupt gleicher ;Prioritaet kann wirksam werden ret ISR_PCA0: djnz R2,ISR_PCA0_ENDE ;Sekunde noch nicht vorbei mov EIE1,#00h ;PCA0-Interrupts sperren setb F0 ;genuegend Interrupts ISR_PCA0_ENDE: ret ;------------------------------------------------------------------------ ; Peripheral specific initialization functions, ; Called from the Init_Device label ;------------------------------------------------------------------------ PCA_Init: mov PCA0CN, #040h anl PCA0MD, #0BFh mov PCA0MD, #009h mov PCA0CPM0, #0C2h mov PCA0CPL0, #031h mov PCA0CPH0, #0F5h 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 - Skipped, Push-Pull, Digital ; P1.1 - CEX0 (PCA), Push-Pull, Digital ; P1.2 - Unassigned, Push-Pull, Digital ; P1.3 - Skipped, Push-Pull, Digital ; P1.4 - Unassigned, Push-Pull, Digital ; P1.5 - Unassigned, Push-Pull, Digital ; P1.6 - Unassigned, Push-Pull, Digital ; P1.7 - Unassigned, Push-Pull, Digital ; P2.0 - Unassigned, Push-Pull, Digital ; P2.1 - Unassigned, Push-Pull, Digital ; P2.2 - Unassigned, Push-Pull, Digital ; P2.3 - Unassigned, Push-Pull, Digital ; P2.4 - Unassigned, 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, #009h mov XBR1, #041h ret Oscillator_Init: mov OSCICN, #081h ret Interrupts_Init: mov IT01CF, #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