[TI-H] Re: PIC16F84 Interfacing
[Prev][Next][Index][Thread]
[TI-H] Re: PIC16F84 Interfacing
On Thu, 09 Aug 2001 20:39:48 -0300 Carlos Becker <cjb@softhome.net>
writes:
> When i connect everything, before executing the program, everything
> slows
> down like if the pic was sending data.
> I think this is an important factor to consider. I don't know what
> I am
> doing wrong but I'm sure it's in the RecvByte routine, see below:
Are you setting both lines to be inputs before calling RecvByte?
Could there be something wrong with the cable/calc?
It sounds like at least one line is being pulled low and the calculator
is trying to recieve data.
Hmm: Are you connecting before or after applying power is applied to the
pic? How does your routine deal with the initial noise generated by
connecting/disconnecting the cable?
I've actually been able to recieve from a TI86 with *no* reisistors at
all, maybe this code could help?
Unfortunately, I no longer know how I set up for it, but I think you need
to set PORTA & TRISA to LINK_MASK (both bits as inputs, both high).
(actually, I'm not completely sure this is the version that works, but
it's all I have now...)
Something else you might want to try (if it fits with your application)
is to switch to using two of bits 4-7 of portb. PORTB has internal
pull-up resistors (if you clear /RBPU) and interrupt-on-change with those
four bits.
LINK_PORT equ PORTA
LINK_TRIS equ TRISA
RED equ 2
WHITE equ 3
LINK_MASK equ B'01100'
link_bits_left equ H'10'
link_byte equ H'11'
link_get_byte:
movlw LINK_TRIS
movwf FSR
movlw 8
movwf link_bits_left
link_get_loop:
call link_get_bit
iorwf link_bits_left,w
btfss STATUS,Z
goto link_get_loop
retlw 0
link_get_bit:
movlw LINK_MASK
andwf LINK_PORT,w
btfsc STATUS,Z
goto link_error
btfss LINK_PORT,RED
goto link_get_0
btfss LINK_PORT,WHITE
goto link_get_1
retlw 0
link_error: ; wait for end of error
movlw LINK_MASK
andwf LINK_PORT,w
btfsc STATUS,Z
goto link_error
movlw 8 ; restart this byte
movwf link_bits_left
retlw 1 ; signal an error
link_get_0:
bcf LINK_PORT,WHITE ; send other line low
bcf INDF,WHITE
rlf link_byte,f
bcf link_byte,0 ; record the bit
link_g0w:
btfss LINK_PORT,RED ; wait for return to high
goto link_g0w
bsf INDF,WHITE ; return other line to high (float)
retlw 0
link_get_1:
bcf LINK_PORT,RED ; other line low
bcf INDF,RED
rlf link_byte,f
bsf link_byte,0 ; record bit
link_g1w:
btfss LINK_PORT,WHITE ; wait for return to high
goto link_g1w
bsf INDF,RED ; send return to high
retlw 0
-josh
________________________________________________________________
GET INTERNET ACCESS FROM JUNO!
Juno offers FREE or PREMIUM Internet access for less!
Join Juno today! For your FREE software, visit:
http://dl.www.juno.com/get/tagj.