PDA

View Full Version : I2C optional label question



F1CHF
- 12th July 2009, 13:55
hello
I have a translation probleme about optional label
on I2C commands ..
explanation given in the help database is :
If the optional Label is included, this label will be jumped to if an
acknowledge is not received from the I2C device.
question :
is it a GOTO or a GOSUB function ?

I have a problem with a SP5055 synthetiser, it is working well
using a I2Cwrite command (output frequency is good)
I try to read the SP5055 to see the value of the Frequency Lock bit
(BIT6 of the register)
As soon as I send I2CREAD either on address @C2 or @C3 the frequency
goes outside the good value ... either down or up !

very strange ...
thanks in advance for your help

aratti
- 12th July 2009, 14:22
is it a GOTO or a GOSUB function ?

GOTO


As soon as I send I2CREAD either on address @C2 or @C3 the frequency
goes outside the good value ... either down or up !

I am not familiar with the device, but very likely these registers are not readable.

Al.

F1CHF
- 12th July 2009, 14:42
thanks for your reply
trust me .. answer is yes
on page 3 (and +) from the SP5055 datasheet
you ca read this
READ MODE
When the device is in the read mode the status data read from
the device on the SDA line takes the form shown in Table 2.
Bit 1 (POR) is the power-on reset indicator and is set to a log
1 if the power supply to the device has dropped below 3V and th
programmed information lost (e.g., when the device is initiall
turned on). The POR is set to 0 when the read sequence i
terminated by a stop command. The outputs are all set to hig
impedance when the device is initially powered up. Bit 2 (FL
indicates whether the device is phase locked, a logic 1 is presen
if the device is locked and a logic 0 if the device is unlocked.

datasheet is here
http://f1chf.free.fr/PDF/SP5055.PDF

and I know friends who handle the FL bit to check
if everything is OK ..

aratti
- 12th July 2009, 16:23
Are you using two different addresses (one for write and one for read)?


WriteAddress %xxxxxxxxx0
ReadAddress %xxxxxxxx1

Were: %xxxxxxx is the binary device address.

Al.

F1CHF
- 12th July 2009, 16:44
Yes
I try @C2 and @C3
the write address is @C2 and it works
for the READ I use both (to see what happens !)
because friends told me that they use @C2 and it works
they told me that PBP add 1 on the address value in a read command ?
That why I try both ...
May be my problem is that I am using a VIDEO sender done for 2400 Mhz range
and I use it on 2335 Mhz (amateur band) and the varicap level is low (near 1,15 volts)
I will try to set up on 2400 Mhz and see what happen ...

by the way, have you an idea about the Optionnal Label on I2C command
is it a GOTO or a GOSUB for you ?

thanks

aratti
- 12th July 2009, 19:13
by the way, have you an idea about the Optionnal Label on I2C command
is it a GOTO or a GOSUB for you ?


As I told you in post#2 is a GOTO comand.

You can put a flag=0 before the I2Cread or I2Cwrite and use the label to direct to a TimeOut label, where you change Flag=1. In this way you will know if you had a timeout problem and discard the reading or writing and redo the process.

Al.

Melanie
- 12th July 2009, 19:25
Are you aware that the ADDRESS and the CONTROL should be a variable and NOT a constant? Leave bit 0 clear of the CONTROL byte... the I2C routines will use it internally.

F1CHF
- 12th July 2009, 22:22
Hi Melanie, still on board, super ! and working on Sunday time !
Aratti .. sorry, I didn't see the word GOTO ...thanks ..
It is clear for me, that the control and address parameters are confusing for me ...
I understand from the example, this is used with Eprom familly
Control parameter is the main address
and
address parametre is used to point to the address location in the Eprom !

I use for long time I2C commands in the simple way like
I2CWRITE DataPin,ClockPin,Control,{Address,}[Value{,Value...}]{,Label}

example :

datapin var PORTA.1
clockpin var PORTA.2
Main:
I2CWRITE datapin,clockpin,$C2,[11,22,33,44],errorI2C
etc ...
etc ...

errorI2C:
flash a led ....
goto Main

As I do not understand Control and address story, I always use this and It works
with a lot of synthetisers (SP5055 familly)
Now I decided to be more serious ! and check the frequency lock flag
(bit 6 of the SP 5055 register)
that why I try to READ like that
flag var byte
I2CREAD datapin,clockpin,$C3, [flag], errorI2C
if flag.6 = 1 then continue
else
goto main
endif

continue:
etc ...
etc ...

nb: $C2 or $C3 I am not sure, but I can check the good value ..

thanks for your help

Melanie
- 13th July 2009, 01:07
You did not understand my post... don't use CONSTANTS but use VARIABLES with I2C commands....

ControlByte var BYTE

.. ..

ControlByte=$C2
I2CREAD datapin,clockpin,ControlByte, [flag], errorI2C

F1CHF
- 13th July 2009, 06:12
Hello Melanie, morning ..
Oupps ...I will trust you as usual
I will test it today
thanks

F1CHF
- 13th July 2009, 17:17
I got it !
it works ..
my error was the missing brackets on the I2CREAD command
it seems that without the bracket the I2CREAD become a I2CWRITE !

I try using address $C2 or using a constant ... same results
thanks to everybody
francois

here is my HUGE code !
'*******************************************
'* Name : TX2300 avec 16F84 *
' Variable Definitions
SCL var PORTA.4
SDA var portA.3
LOCKBYTE var byte

Main:
I2CWRITE SDA,SCL,$C2,[$48,$F8,$AE,$FF],errorload
LOCK:
pause 100
I2CREAD SDA,SCL,$C2,[lockbyte]
Lcdout $FE, 1 ' Clear LCD screen
pause 50
lcdout "lock=", #lockbyte, " bit=", #lockbyte.6
pause 1000
goto lock

errorload:
Lcdout $FE, 1 ' Clear LCD screen
pause 50
lcdout "error load "
pause 1000
goto main