string&i2c


Closed Thread
Results 1 to 5 of 5

Thread: string&i2c

Hybrid View

  1. #1
    cesurcelik's Avatar
    cesurcelik Guest

    Default string&i2c

    hi all.
    what i want to do is sending string from pc-hyperterminal via pic16f876 to i2c then reading i2c
    my code is:
    INCLUDE "MODEDEFS.BAS"
    DEFINE CHAR_PACING 65000
    DEFINE OSC 20
    CONTROL CON $A0
    DPIN VAR PORTC.4
    CPIN VAR PORTC.3
    VALUE VAR BYTE[21]
    ADDRESS VAR BYTE

    SERIN2 PORTC.7,396,[WAIT("Ee"),STR VALUE \ 21]

    ADDRESS=0
    WRITEX:

    FOR ADDRESS=0 TO 20
    I2CWRITE DPIN,CPIN,CONTROL,ADDRESS,[VALUE]
    PAUSE 10
    NEXT ADDRESS


    READX:

    FOR ADDRESS=0 TO 20

    I2CREAD DPIN,CPIN,CONTROL,ADDRESS,[VALUE]
    SEROUT2 PORTC.6,396,[#ADDRESS,"=",VALUE[ADDRESS],10,13]
    NEXT ADDRESS
    LOOP:
    GOTO LOOP
    END


    when i send "EeABCDEFGHIJKLMNPRSTUV" to i2c
    the response is:

    Òú
    1:B
    2:C
    3
    4:E
    5:F
    6:G
    7:H
    8:I
    9:J
    10:K
    11:L
    12:M
    13:N
    14:P
    15:R
    16:S
    17:T
    18:U
    19:V
    20:
    as you see the ,i can't read the first address and value(0=A),i don't understand why?

    tank you
    Last edited by cesurcelik; - 17th February 2006 at 16:44.

  2. #2
    beto's Avatar
    beto Guest


    Did you find this post helpful? Yes | No

    Default

    May be Your write Routine, test this:

    WriteX
    FOR ADDRESS=0 TO 20
    I2CWRITE DPIN,CPIN,CONTROL,ADDRESS,VALUE[ADDRESS]
    PAUSE 10
    NEXT ADDRESS

  3. #3
    cesurcelik's Avatar
    cesurcelik Guest


    Did you find this post helpful? Yes | No

    Default

    @beto
    tanks for quick response.
    i've alredy tryed what you said.but the responce is

    êú
    1=B
    2=C
    3=D
    4=E
    5=F
    6=G
    7=H
    8=I
    9=J
    10=K
    11=L
    12=M
    13=N
    14=P
    15=R
    16=S
    17=T
    18=U
    19=V
    20=

    there is no change
    Last edited by cesurcelik; - 17th February 2006 at 17:14.

  4. #4
    beto's Avatar
    beto Guest


    Did you find this post helpful? Yes | No

    Default

    You are using level shifters?, the problem then looks as voltage chirp, if you is using only resistors then try to set High the TX pin BEFORE Data transmition!

  5. #5
    cesurcelik's Avatar
    cesurcelik Guest


    Did you find this post helpful? Yes | No

    Default

    @beto
    thanks again
    i did it as you said
    now the response is:

    0=ÿ
    1=B
    2=C
    3=D
    4=E
    5=F
    6=G
    7=H
    8=I
    9=J
    10=K
    11=L
    12=M
    13=N
    14=P
    15=R
    16=S
    17=T
    18=U
    19=V
    20=

    i can see first address but not correct value

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts