$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 (VC_2_IND_DADR.A51) ;------------------------------------------------------------------------ ;Programmbeschreibung ;------------------------------------------------------------------------ ;Programm: ;T1-->00 in DSEG 30h bis FFh ;T2-->FFh in DSEG 30h bis FFh ;Indirekte Adressierung ;DSEG = ISEG von 00h bis 7Fh ; ;Erstellt am: Freitag, 9. Januar 2009 21:00:42 ;Programmiert: Juergen Walter ; ;Verwendete Einspruenge: keine ; ;Verwendete Unterprogramme: keine ; ; ;Verwendete Register und Variable: ;Registerbank(0) ;R2 ; ;Kommentar: ; ;Aenderungen: ;Geaendert am: Freitag, 9. Januar 2009 21:00:42 ; ; ;------------------------------------------------------------------------ ;Initialisierungsteil fuer allgemeine Konstanten ;------------------------------------------------------------------------ CSEG AT 0H ;Legt absolute Codesegmentadresse auf 0h jmp INIT ; ;------------------------------------------------------------------------ ;Interrupt-Vektoren ;------------------------------------------------------------------------ ;ORG ;------------------------------------------------------------------------ ;Initialisierungsteil fuer On-Chip Peripherie ;------------------------------------------------------------------------ ORG 100H ;Programmstart bei 100H INIT: call Init_Device ;Aufruf zur Initialisierung der Controller Funktionen ;------------------------------------------------------------------------ ;Programmschleife ;------------------------------------------------------------------------ ABFRAGE: jnb P1.1,DSEG_00 ;T1 jnb P1.2,DSEG_FF ;T2 jmp ABFRAGE DSEG_00: mov ACC,#0h ;lade ACCU mit 0 mov R0,#030h ;initialisiere R0 mit 30h mov R2,#0D0h ;lade Zaehlregister R2 mit D0h Adressen - Werten SCHLEIFE1: mov @R0,ACC ;schreibe Inhalt von akku in die Adresse auf die R0 steht inc R0 ;erhöhe R0 um eins djnz R2,SCHLEIFE1 ;erniedrige R2 um eins, falls nicht 0 springe auf SCHLEIFE1 jmp ABFRAGE ;sprung zur ABFRAGE DSEG_FF: mov A,#0FFh ;lade akku mit 5Ah mov R0,#030h ;initialisiere R0 mit 30h mov R2,#0D0h ;lade Zaehlregister R2 mit D0h Adress - Werten SCHLEIFE2: mov @R0,A ;schreibe Inhalt von akku in die Adresse auf die R0 steht inc R0 ;erhöhe R0 um eins djnz R2,SCHLEIFE2 ;erniedrige R2 um eins, falls nicht 0 springe auf SCHLEIFE1 jmp ABFRAGE ;Sprung zur ABFRAGE ;------------------------------------------------------------------------ ; Peripheral specific initialization functions, ; Called from the Init_Device label ;------------------------------------------------------------------------ PCA_Init: anl PCA0MD, #0BFh mov PCA0MD, #000h ret Port_IO_Init: ; P0.0 - Unassigned, Push-Pull, Digital ; P0.1 - Unassigned, Push-Pull, Digital ; P0.2 - Unassigned, Push-Pull, Digital ; P0.3 - Unassigned, Push-Pull, Digital ; P0.4 - Unassigned, Push-Pull, Digital ; P0.5 - Unassigned, Push-Pull, Digital ; P0.6 - Unassigned, Push-Pull, Digital ; P0.7 - Unassigned, Push-Pull, Digital ; P1.0 - Unassigned, Push-Pull, Digital ; P1.1 - Skipped, Push-Pull, Digital ; P1.2 - Skipped, 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 - Skipped, Push-Pull, Digital ; P3.3 - Skipped, Push-Pull, Digital ; P3.4 - Skipped, 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 P1SKIP, #00Eh mov P3SKIP, #01Ch mov XBR1, #040h ret Oscillator_Init: mov OSCICN, #083h mov CLKMUL, #080h clr A ; Wait 5us for initialization djnz ACC, $ orl CLKMUL, #0C0h Osc_Wait2: mov A, CLKMUL jnb ACC.5, Osc_Wait2 ret ; Initialization function for device, ; Call Init_Device from your main program Init_Device: lcall PCA_Init lcall Port_IO_Init lcall Oscillator_Init ret end