Shop OBEX P1 Docs P2 Docs Learn Events
I2C on the SX52 — Parallax Forums

I2C on the SX52

sirnfssirnfs Posts: 3
edited 2005-11-10 07:41 in General Discussion
Hello,

I am trying to communicate with a CMOS image sensor via I2C.· The image sensor uses a serial format called SCCB, which is identical to I2C as far as I can tell.· The SCCB data sheet can be found here:· http://www.ovt.com/pdfs/ds_note.pdf

I am using the SX52 as well as SX/B.· I have attempted to troubleshoot the code with the Debugger using the SX Key oscillator, but·I am not even sure that this is possible (timing issues?).· The code is shown below.· Note:· (2) 4.7 kohm pull-up·resistors are being used on the SDA pin (RE.0) and SCL pin (RE.1).· I have also noticed what seems to be some sort of·contention.· When I attempt to enter Debug mode, the programming process will freeze.· To get rid of this problem, i power-down the SX52 and then reapply power.· I realize that there it is not possible to test this code, but I would appreciate if anyone could take a look at the code or·possibly comment on a solution.·

Thanks,

Mike·

'
' Device Settings
'
DEVICE SX52, OSCHS3
IRC_CAL IRC_SLOW
FREQ 5000000
PROGRAM start_point
'
' Variables
'
Ack CON 0
Nak CON 1
SDA CON "RE.0"
Recv VAR bit
tmp VAR byte
tmp2 VAR byte
sndcode CON $C0
regnum CON $1C
sndcode2 CON $C1
'
' Program Code
'
start_point:
I2CSTART SDA··········· ' start transmission
I2CSEND SDA, sndcode·' send id address
I2CSEND SDA, regnum, Recv ' send sub-address
I2CSTART SDA··' restart new transmission
I2CSEND SDA, sndcode·' send id address again
I2CRECV SDA, tmp2, Nak· ' receive data from slave
I2CSTOP SDA··' stop transmission
__RAM($1F) = tmp2·' store received data to RAM

BREAK
SLEEP

·

Comments

  • sirnfssirnfs Posts: 3
    edited 2005-11-10 04:24
    I forgot to mention that the code is NOT working. The value in RAM($1F) is not changing, though the code will execute until it reaches the BREAK statement.
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-11-10 07:41
    Hello,

    I had a brief look at the SCCB datasheet section where the serial communication is described. Seems to me that the ninth bit following the address or data bytes is handled differently by this device. Usually, this bit is the acknowledge bit to be pulled low by the receiving device to acknowledge the byte revceived. The SCCB datasheet calls this a don't care bit, and on first reading, I did not fully figure out if it is handled correctly according to the I²C specs. If not, the SX/B I²C routines might have problems, or assume a no acknowledge situation.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    Günther
Sign In or Register to comment.