Re: TI-H: Port voltage
[Prev][Next][Index][Thread]
Re: TI-H: Port voltage
TI Protocol.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Receives byte using TI protocol ;
; Returns with z set if errored out.. otherwise byte = a ;
; IT IS CRUCIAL THAT THE STACK IS CLEAN WHEN THIS IS CALLED ;
; BECAUSE IF IT ERRORS OUT IT'LL DO -TWO- RETs TO RETURN TO ;
; HIGHEST LEVEL API CALL ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
rec_byte: ;
push bc ; Back 'em up... destroyed
push de ;
ld b,$08 ; 8 bits..
r0:
ld de,$FFFF ;
; jr r2 ;
r1:
in a,(port) ;
and $03 ; Both low?
jr z,linkerr ; That's an instant error
cp $03 ; Both high?
jr nz,r3 ; No... go to r3
; in a,(port) ;
; and $03 ;
; jr z,linkerr ;
; cp $03 ;
; jr nz,r3 ;
r2:
dec de ; Decrease counter...
ld a,d ; Is de at 0 yet?
or e ;
jr nz,r1 ;
jr linkerr ; Yes it is, return
r3:
sub $02 ; Which line is active?
jr nc,r8 ; Line 2 (bit 1)
ld a,$D4 ; Bit 0...
out (port),a ;
rr c ;
ld de,$FFFF ;
; nop
; nop
; nop
; nop
r4:
in a,(port) ;
and $03 ; Clear out everything but first two
cp $02 ; Line 1 clear?
jr z,r5 ;
dec de ; Line 2 is clear...
ld a,d ;
or e ;
jr nz,r4 ;
jr linkerr ; Timeout...
r5:
ld a,$C0 ;
out (port),a ;
ld d,$04 ;
; nop
; nop
; nop
; nop
r6:
dec d ;
jr z,r7 ;
in a,(port) ;
and $03 ;
cp $03 ;
jr nz,r6 ;
r7:
djnz r0 ;
ld a,c ;
jr linkok ;
r8:
ld a,$E8 ;
out (port),a ;
rr c ;
ld de,$FFFF ;
; nop
; nop
; nop
; nop
r9:
in a,(port) ;
and $03 ;
cp $01 ;
jr z,r5 ;
dec de ;
ld a,d ;
or e ;
jr nz,r9 ; Errored out...
linkerr: ; Cheap stack tricks, but it works..
ld sp,(spbak) ; Backup stack pointer... save us
ld a,$C0 ;
out (port),a ;
ld a,(varactive) ;
or a ;
jr z,disp_to ;
; ld hl,buffer2-2 ;
; rst 20h ; Copy to op1
; rst 10h ; Find sym
; jr c,disp_to ; Not found, wierd but not found
; call _delvar ; Delete variable, timed out...
ld hl,$3045 ; Display variable destroyed msg
ld (CURSOR_X),hl ;
ld hl,&vd ;
call D_ZM_STR ;
disp_to:
ld hl,$3030 ; Setup for number display
ld (CURSOR_X),hl ;
ld hl,&to ; Display
call D_ZM_STR ; Display time out string...
jp &exitpause ; Return to main menu
linkok:
pop de ; Just get vars back and return
pop bc ;
ret ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Sends byte out using TI protocol ;
; Input: a ;
; Returns with z set if errored out... ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
send_byte:
push bc ; Back up destroyed registers
push de ;
ld c,a
ld b,$08 ;
s0:
ld de,$FFFF ;
rr c ;
jr nc,s1 ; Send a 0
ld a,$E8 ; %11101000 -- Activate red wire
jr s2 ;
s1:
ld a,$D4 ; %11010100 -- Activate white wire
s2:
out (port),a ;
; nop
; nop
; nop
; nop
s3:
in a,(port) ;
and $03 ; Both low?
jr z,s4 ;
; in a,(port) ;
; and $03 ;
; jr z,s4 ;
dec de ;
ld a,d ;
or e ;
jr nz,s3 ;
jr linkerr ; We've errored out
s4:
ld a,$C0 ; %110000000 -- Activate both wires?
out (port),a ;
ld de,$FFFF ;
; nop
; nop
; nop
; nop
s5:
dec de ;
ld a,d ;
or e ;
jr z,linkerr ;
in a,(port) ;
and $03 ;
cp $03 ; Both high?
jr nz,s5 ;
djnz s0 ;
jr linkok
>Where can I find documentation on the TIP Protocol?
>
>*********** REPLY SEPARATOR ***********
>
>On 10/24/98, at 4:57 PM, Grant Stockly wrote:
>
>>No. `5v is a 1, `0v is a 0.
>>
>>You must use tip or another type of handshaking to receive one bit at a time.
>>
>>Grant
>>
>>
>>
>>>So how would I go about determining if its 1 or 0? Do these 1 and 0s come
>>>in multiples of 4 to create a byte? and what is the alternate method you
>>>refered to as tips?
>>>
>>>Thanx vb5man@usa.net
>>>
>>>*********** REPLY SEPARATOR ***********
>>>
>>>On 10/24/98, at 3:38 PM, Grant Stockly wrote:
>>>
>>>>>Does the TI link port have a certain voltage for each character sent
>>>>>during a transmission?
>>>>>If not, how could I interprete the data using circuitry or voltage?
>>>>
>>>>No. Its not an analogue signal.
>>>>
>>>>its either 1, or 0. You have to either make a protocol or use tip.
>>>>
>>>>Grant
References: