Ja das funktioniert, aber es wird alles zu unübersichtlich.
Hab grade mal den Befehl der erste einegebunden Datei (include ???.asm)
durch den gesammten Quelltext der Datei (???.asm) ersetzt und mir ist
aufgefallen das er nicht mal den Sprungbefehl in dieser einen Datei
ausführen kann, ca 20 Zeilen!
Nehme ich nun die ganzen anderen eingebundenen Dateien heraus die
hinter der ersten Datei stehen, kann er alle Befehle ausführen?!
Wie kann das denn?!
Hab mal versucht zu veranschaulichen was ich gemacht habe:
1.
INCLUDE 89C2051.mc
LJMP init
INCLUDE regenmesser.asm
INCLUDE i2c.asm <---- Sprungfehler
INCLUDE crc8.asm
INCLUDE umwandeln.asm
INCLUDE temp.asm
INCLUDE lcd.asm
INCLUDE windmesser.asm
INCLUDE Wait.asm
INCLUDE heizung.asm
INCLUDE senden.asm
INCLUDE klima.asm........
..................................................................
2.
INCLUDE 89C2051.mc
LJMP init
INCLUDE regenmesser.asm
;----------Befehle für I2c Bus----------
sda EQU p3.1 ;I2C Datenleitung
scl EQU p3.2 ;I2C Clockimpuls
error BIT 5fh ;wird gesetzt wenn I2C übertragung gescheitert
write_i2c:
LCALL start_i2c
LCALL addy_w
LCALL ack
LCALL send_data_i2c <----- Hier liegt der Sprungfehler
LCALL ack
LCALL STOP_i2c
RET
read_i2c:
LCALL start_i2c
LCALL addy_r
LCALL ack
LCALL read_data_i2c
LCALL send_ack
LCALL STOP_i2c
RET
scl_i2c:
SETB scl
LCALL wait_i2c
CLR scl
LCALL wait_i2c
RET
start_i2c:
SETB sda
SETB scl
LCALL wait_i2c
CLR sda
lcall wait_i2c
CLR scl
LCALL wait_i2c
RET
stop_i2c:
CLR sda
SETB scl
LCALL wait_i2c
SETB sda
LCALL wait_i2c
CLR scl
LCALL wait_i2c
CLR sda
RET
addy_r:
PUSH A
MOV R7,#08h
INC R6
MOV A,R6
poi4: RLC A
MOV sda,C
LCALL scl_i2c
DJNZ R7,poi4
DEC R6
POP A
ret
addy_w:
PUSH A
MOV R7,#08h
MOV A,R6
poi1: RLC A
MOV sda,C
LCALL scl_i2c
DJNZ R7,poi1
POP A
ret
ack:
CLR error
SETB sda
LCALL wait_i2c
SETB scl
JNB sda,poi5
SETB error
CLR sda
poi5: CLR scl
RET
send_ack:
SETB sda
SETB scl
LCALL wait_i2c
CLR scl
LCALL wait_i2c
CLR sda
RET
send_ack_n:
CLR sda
SETB scl
LCALL wait_i2c
CLR scl
LCALL wait_i2c
CLR sda
RET
send_data_i2c: <---- Hier, nicht zu erreichendes Sprungziel
MOV R7,#08h
poi2: RLC A
MOV sda,C
NOP
LCALL scl_i2c
DJNZ R7,poi2
RET
read_data_i2c:
MOV R7,#08h
poi3: SETB scl
LCALL wait_i2c
MOV C,sda
RLC A
CLR scl
LCALL wait_i2c
DJNZ R7,poi3
RET
wait_i2c:
NOP
NOP
NOP
NOP
NOP
NOP
RET
INCLUDE crc8.asm
INCLUDE umwandeln.asm
INCLUDE temp.asm
INCLUDE lcd.asm
INCLUDE windmesser.asm
INCLUDE Wait.asm
INCLUDE heizung.asm
INCLUDE senden.asm
INCLUDE klima.asm
....................................................................
3. Wenn die eingebundenen Dateien weg sind, dann läuft es?!!!!
INCLUDE 89C2051.mc
LJMP init
INCLUDE regenmesser.asm
;----------Befehle für I2c Bus----------
sda EQU p3.1 ;I2C Datenleitung
scl EQU p3.2 ;I2C Clockimpuls
error BIT 5fh ;wird gesetzt wenn I2C übertragung gescheitert
write_i2c:
LCALL start_i2c
LCALL addy_w
LCALL ack
LCALL send_data_i2c
LCALL ack
LCALL STOP_i2c
RET
read_i2c:
LCALL start_i2c
LCALL addy_r
LCALL ack
LCALL read_data_i2c
LCALL send_ack
LCALL STOP_i2c
RET
scl_i2c:
SETB scl
LCALL wait_i2c
CLR scl
LCALL wait_i2c
RET
start_i2c:
SETB sda
SETB scl
LCALL wait_i2c
CLR sda
lcall wait_i2c
CLR scl
LCALL wait_i2c
RET
stop_i2c:
CLR sda
SETB scl
LCALL wait_i2c
SETB sda
LCALL wait_i2c
CLR scl
LCALL wait_i2c
CLR sda
RET
addy_r:
PUSH A
MOV R7,#08h
INC R6
MOV A,R6
poi4: RLC A
MOV sda,C
LCALL scl_i2c
DJNZ R7,poi4
DEC R6
POP A
ret
addy_w:
PUSH A
MOV R7,#08h
MOV A,R6
poi1: RLC A
MOV sda,C
LCALL scl_i2c
DJNZ R7,poi1
POP A
ret
ack:
CLR error
SETB sda
LCALL wait_i2c
SETB scl
JNB sda,poi5
SETB error
CLR sda
poi5: CLR scl
RET
send_ack:
SETB sda
SETB scl
LCALL wait_i2c
CLR scl
LCALL wait_i2c
CLR sda
RET
send_ack_n:
CLR sda
SETB scl
LCALL wait_i2c
CLR scl
LCALL wait_i2c
CLR sda
RET
send_data_i2c:
MOV R7,#08h
poi2: RLC A
MOV sda,C
NOP
LCALL scl_i2c
DJNZ R7,poi2
RET
read_data_i2c:
MOV R7,#08h
poi3: SETB scl
LCALL wait_i2c
MOV C,sda
RLC A
CLR scl
LCALL wait_i2c
DJNZ R7,poi3
RET
wait_i2c:
NOP
NOP
NOP
NOP
NOP
NOP
RET
END