All right, by looking into Sega SDK\SEGADTS\32X\DEMO\SOJ_32X, I could achieve something (well, I sent a byte from Master to Slave on real Hardware).
Here's the stuff:
Code: Select all
initMaster:
* ...
MOV #$80,R4
MOV #74,R5
MOV #$20,R6 ; TE | SCK is output
BSR initSci
NOP
* ...
with
Code: Select all
initSci:
* IN R4 SMR
* R5 BRR
* R6 SCR
STS.L PR,@-R15
MOV.L R0,@-R15
MOV.L R1,@-R15
MOV.W !SCI_REGS,R1
MOV #0,R0
MOV.B R0,@(2,R1) ; Clear TE and RE bits in SCR to 0
MOV R4,R0 ; C//A | CKS0
MOV.B R0,@R1 ; Set SMR
MOV R5,R0
MOV.B R0,@(1,R1) ; Set BRR
MOV #0,R0
MOV.B R0,@(2,R1) ; Clear SCR
MOV R5,R0
SHLL2 R0
!waitABit:
NOP
DT R0
BF !waitABit
MOV R6,R0
MOV.B R0,@(2,R1) ; Set SCR
MOV.L @R15+,R1
MOV.L @R15+,R0
LDS.L @R15+,PR
RTS
NOP
!SCI_REGS DC.W $FE00
Then, on the slave side :
Code: Select all
initSlave:
* ...
MOV #$80,R4
MOV #74,R5
MOV #$12,R6 ; RE | SCK is input
BSR initSci
NOP
* ...
Now, for sending, from the Master:
Code: Select all
send:
* IN R4 data
STS.L PR,@-R15
MOV.L R0,@-R15
MOV.L R1,@-R15
MOV.W !SCI_REGS,R1
!waitForTDRESet:
mov.b @(4,r1),r0
tst #%10000000,r0 ; if (TDRE == 0), 1 -> T
bt !waitForTDRESet
mov r4,r0
mov.b r0,@(3,r1)
!waitForTENDSet:
mov.b @(4,r1),r0
tst #%00000100,r0 ; if (TEND == 0), 1 -> T
bt !waitForTENDSet
mov #0,r0
mov.b r0,@(4,r1) ; Clear SSR
MOV.L @R15+,R1
MOV.L @R15+,R0
LDS.L @R15+,PR
RTS
NOP
!SCI_REGS DC.W $FE00
Finally, for the Slave to receive :
Code: Select all
receive:
* OUT R0 data
STS.L PR,@-R15
MOV.L R1,@-R15
MOV.L R2,@-R15
MOV.W !SCI_REGS,R1
mov #%00010000,r0
mov.b r0,@(2,r1) ; Set RE
mov.b @(4,r1),r0
tst #%01000000,r0 ; if (RDRF == 0), 1 -> T
bt !noData
mov.b @(5,r1),r0 ; Read RDR
MOV R0,R2
mov #0,r0
mov.b r0,@(4,r1) ; Clear SSR
mov.b r0,@(2,r1) ; Clear SCR, Reset RE
MOV R2,R0
!epilog:
MOV.L @R15+,R2
MOV.L @R15+,R1
LDS.L @R15+,PR
RTS
NOP
!SCI_REGS DC.W $FE00
!noData:
MOV #-2,R0
BRA !epilog
NOP
As you can see, I don't bother with ORER, but it was just a quick and dirty test.
- CommPort.B[6] ("07") is the byte sent
CommPort.B[7] ("01") is the number of bytes received - IMG_2738.jpg (83.7 KiB) Viewed 5091 times
Truth is, it's a lot of hassle (not very well emulated, not very well documented), for not so much of a result.