-
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: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:
as you see the ,i can't read the first address and value(0=A),i don't understand why?
tank you
-
May be Your write Routine, test this:
WriteX
FOR ADDRESS=0 TO 20
I2CWRITE DPIN,CPIN,CONTROL,ADDRESS,VALUE[ADDRESS]
PAUSE 10
NEXT ADDRESS
-
@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
-
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!
-
@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