Re: Talking to the IPC: How do you do it from low level?
Posted: Mon Apr 28, 2025 5:23 pm
For the IPC > ZX8302 the communication is similar:
;
; Send 8 bits
;
IPC_Send_8:
mov r5,#008H
jmp L0358
;
; Send 4 bits
;
IPC_Send_4:
swap a
mov r5,#004H
L0358:
rl a
mov r6,a
jb0 L0369
L035C:
in a,p2
jb7 L035C
movx @r0,a
anl p2,#07FH
movx @r0,a
orl p2,#080H
mov a,r6
djnz r5,L0358
ret
;
L0369:
in a,p2
jb7 L0369
movx @r0,a
orl p2,#080H
movx @r0,a
mov a,r6
djnz r5,L0358
ret
R5 is used as a loop counter - doing either 4 or 8 passes. At L035C - we read P2 port looking for it to drop to 0 - in other words - we can't transmit any bits until the ZX8302 tells us by dropping COMDATA to 0.
Depending on whether the bit to be sent is a 0 or 1:
If a 0 is to be sent :
As soon as we see COMDATA go to 0 we pulse /WR line low on the IPC (bit 6 of the port for reading IPC (COMCTL), and then perform a literal AND on P2 (preserve other values on the port but reset bit 7 - this sends a 0 on COMMDATA and we send another /WR pulse (COMCTL) and then set COMDATA back to 1 and loop around for the next bit
If a 1 is to be sent:
As soon as we see COMDATA go to 0 we pulse /WR line low on the IPC (bit 6 of the port for reading IPC (COMCTL), and then perform a literal OR on P2 (preserve other values on the port but set bit 7 - this sends a 1 on COMMDATA and we send another /WR pulse (COMCTL) and loop around for the next bit
So in both cases for writing bits - COMCTL will pulse low twice - once before and once after the bit sent, and in both cases we wait for COMDATA to go low before we send anything, leaving it high after sending
;
; Send 8 bits
;
IPC_Send_8:
mov r5,#008H
jmp L0358
;
; Send 4 bits
;
IPC_Send_4:
swap a
mov r5,#004H
L0358:
rl a
mov r6,a
jb0 L0369
L035C:
in a,p2
jb7 L035C
movx @r0,a
anl p2,#07FH
movx @r0,a
orl p2,#080H
mov a,r6
djnz r5,L0358
ret
;
L0369:
in a,p2
jb7 L0369
movx @r0,a
orl p2,#080H
movx @r0,a
mov a,r6
djnz r5,L0358
ret
R5 is used as a loop counter - doing either 4 or 8 passes. At L035C - we read P2 port looking for it to drop to 0 - in other words - we can't transmit any bits until the ZX8302 tells us by dropping COMDATA to 0.
Depending on whether the bit to be sent is a 0 or 1:
If a 0 is to be sent :
As soon as we see COMDATA go to 0 we pulse /WR line low on the IPC (bit 6 of the port for reading IPC (COMCTL), and then perform a literal AND on P2 (preserve other values on the port but reset bit 7 - this sends a 0 on COMMDATA and we send another /WR pulse (COMCTL) and then set COMDATA back to 1 and loop around for the next bit
If a 1 is to be sent:
As soon as we see COMDATA go to 0 we pulse /WR line low on the IPC (bit 6 of the port for reading IPC (COMCTL), and then perform a literal OR on P2 (preserve other values on the port but set bit 7 - this sends a 1 on COMMDATA and we send another /WR pulse (COMCTL) and loop around for the next bit
So in both cases for writing bits - COMCTL will pulse low twice - once before and once after the bit sent, and in both cases we wait for COMDATA to go low before we send anything, leaving it high after sending