Hello,
i want to have two microcontrollers set up with a clock and data wire between them, there will be three switches on one microcontroller and three led's on the other... on the transmitting microcontroller i have ths code but it doesnt seem to send out the right pattern. any help on debugging it will be apreciated.
*******************START OF CODE ***********************
$include (reg66x.INC)
; CLOCK IS SET AT 10,000 PER SECOND THROUGH P2.1, DATA IS SET ON P2.2
; DATA RATE SHOULD BE 10Kbps
; SHOULD SEND 10111SSS, S BEING THE SWITCH VALUE.
ORG 0
SJMP START
ORG 40H
START:
; START BY READING IN THE SWITCHS AND MASKING THE BYTE
MOV A,P1
ANL A,#07H
ACALL SEND1 ;SENDING 1 THROUGH THE DATA PIN
ACALL SEND0 ;SENDING 0 THROUGH THE DATA PIN
;SENDING THREE 1'S THROUGH THE DATA PIN
MOV R3,3
AGAIN:
ACALL SEND1
DJNZ R3,AGAIN
;SENDING THE SWITCH VALUES THROUGH THE DATA PIN
MOV R3,3
AGAIN1:
ACALL SDATA
DJNZ R3,AGAIN1
JMP START
;SENDS 1 THROUGH THE DATA PIN P2.2
SEND1:
SETB P2.1
ACALL DELAY
SETB P2.2
ACALL DELAY
CLR P2.1
ACALL DELAY
CLR P2.2
ACALL DELAY
RET
;SENDS 0 THROUGH DATA PIN 2.2
SEND0:
SETB P2.1
ACALL DELAY
ACALL DELAY
CLR P2.1
ACALL DELAY
ACALL DELAY
RET
;READS THE SWITCH VALUE EITHER SEND 1 OR 0 DEPENDING ON VALUE
SDATA:
RLC A
JC SDATA1
ACALL SEND0
SDATA1:
ACALL SEND1
RET
;DELAY OF 0.05MS
DELAY:
MOV R0,#44
AGAIN2:
DJNZ R0,AGAIN2
RET
END
****************** END OF CODE ***********************
i want to have two microcontrollers set up with a clock and data wire between them, there will be three switches on one microcontroller and three led's on the other... on the transmitting microcontroller i have ths code but it doesnt seem to send out the right pattern. any help on debugging it will be apreciated.
*******************START OF CODE ***********************
$include (reg66x.INC)
; CLOCK IS SET AT 10,000 PER SECOND THROUGH P2.1, DATA IS SET ON P2.2
; DATA RATE SHOULD BE 10Kbps
; SHOULD SEND 10111SSS, S BEING THE SWITCH VALUE.
ORG 0
SJMP START
ORG 40H
START:
; START BY READING IN THE SWITCHS AND MASKING THE BYTE
MOV A,P1
ANL A,#07H
ACALL SEND1 ;SENDING 1 THROUGH THE DATA PIN
ACALL SEND0 ;SENDING 0 THROUGH THE DATA PIN
;SENDING THREE 1'S THROUGH THE DATA PIN
MOV R3,3
AGAIN:
ACALL SEND1
DJNZ R3,AGAIN
;SENDING THE SWITCH VALUES THROUGH THE DATA PIN
MOV R3,3
AGAIN1:
ACALL SDATA
DJNZ R3,AGAIN1
JMP START
;SENDS 1 THROUGH THE DATA PIN P2.2
SEND1:
SETB P2.1
ACALL DELAY
SETB P2.2
ACALL DELAY
CLR P2.1
ACALL DELAY
CLR P2.2
ACALL DELAY
RET
;SENDS 0 THROUGH DATA PIN 2.2
SEND0:
SETB P2.1
ACALL DELAY
ACALL DELAY
CLR P2.1
ACALL DELAY
ACALL DELAY
RET
;READS THE SWITCH VALUE EITHER SEND 1 OR 0 DEPENDING ON VALUE
SDATA:
RLC A
JC SDATA1
ACALL SEND0
SDATA1:
ACALL SEND1
RET
;DELAY OF 0.05MS
DELAY:
MOV R0,#44
AGAIN2:
DJNZ R0,AGAIN2
RET
END
****************** END OF CODE ***********************