AN10397 How to use the SC18IM700 to control any I2C-bus device

trol other I
2
C-bus slave devices.
AN10397_1
Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Application note
Rev. 01 5 December 2005
2 of 10
Philips Semiconductors
AN10397
How to use the SC18IM700 to control any I
2
C-bus device
Contact information
For additional information, please visit: http://www.semiconductors.philips.com
For sales office addresses, please send an email to: sales.addresses@www.semiconductors.philips.com
Revision history
Rev
Date
Description
01
20051205
Application note; initial version. AN10397_1
Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Application note
Rev. 01 5 December 2005
3 of 10
Philips Semiconductors
AN10397
How to use the SC18IM700 to control any I
2
C-bus device

1.
Introduction
Philips Semiconductors recently introduced a whole new family of devices called
the Bridges. These devices are intended to transform data from one serial bus to another
serial bus, and this transformation allows the host to control devices that have serial host
bus interfaces that are not native to the system.
One such scenario is the I
2
C-bus interface. There are wide ranges of devices that have an
I
2
C-bus interface to communicate with a host. Some of such devices are: EEPROMs,
temperature
sensors, analog-to-digital or digital-to-analog converters, LED blinkers and
I/O expanders. To use these devices in the system, a host must have an integrated
I
2
C-bus controller on-board, or it must have an external, stand-alone I
2
C-bus controller.
Philips Semiconductors SC18IM700an I
2
C-bus controller with a UART host interface
is the perfect choice in the case where the host does not have an integrated I
2
C-bus
controller on-board, and the system designer wishes to use I
2
C-bus related devices in the
system. The SC18IM700 does not require any programming at all other than the code to
write and read from the hosts UART port. This non-programming is possible because
SC18IM700 communicates with the host through a series of messages that are based on
ASCII characters.
This application note shows how a host can control, setup, read and write to any I
2
C-bus
devices through this UART-to-I
2
C controller. The examples used in this application note
are built around an LED blinker from Philips Semiconductors, the PCA9531. Besides the
I
2
C-bus control function, the SC18IM700 also contains a general-purpose 8-bit
programmable I/O port. These eight general purpose I/O pins can be configured to the
following modes: input only, open-drain output, push-pull output or quasi-bidirectional
input/output.
2.
PCA9531: LED blinker
The PCA9531 is an 8-bit I
2
C-bus and SMBus I/O expander optimized for dimming LEDs in
256 discrete steps for Red/Green/Blue (RGB) color mixing and backlight applications.
The initial setup sequence programs the two blink rates and duty cycles for each individual
PWM. From then on, only one command from the bus master is required to turn individual
LEDs ON, OFF, BLINK RATE 1 or BLINK RATE 2. Based on the programmed frequency
and duty cycle, BLINK RATE 1 and BLINK RATE 2 will cause the LEDs to appear at a
different brightness or blink at periods up to 1.69 second. The open-drain outputs directly
drive the LEDs with maximum output sink current of 25 mA per bit and 100 mA per
package.
Please refer to the PCA9531 data sheet for more detail about this device and its internal
registers usage. The following steps to program the part are extracted from the example
in the data sheet, page 11. AN10397_1
Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Application note
Rev. 01 5 December 2005
4 of 10
Philips Semiconductors
AN10397
How to use the SC18IM700 to control any I
2
C-bus device

2.1 Programming example
The following example will show how to set LED0 to LED3 on. It will then set LED4 and
LED5 to blink at 1 Hz at a 50 % duty cycle. LED6 and LED7 will be set to be dimmed at
25 % of their maximum brightness (duty cycle = 25 %).
[1]
This column shows the steps needed to be performed by the host to set the LED to blink at a specified rate.
Table 1:
PCA9531 programming example
Programming step
I
2
C-bus data
[1]
START
S
PCA9531 address with A0, A1, A2 = LOW
C0h
PSC0 subaddress + auto-increment
11h
Set prescaler PSC0 to achieve a period of 1 second:
PSC0 = 151
97h
Set PWM0 duty cycle to 50 %:
PWM0 = 128
80h
Set prescaler PCS1 to dim at maximum frequency:
PSC1 = 0
00h
Set PWM1 output duty cycle to 25 %:
PWM1 = 64
40h
Set LED0 to LED3 on
55h
Set LED4, LED5 to PWM0, and LED6, LED7 to PWM1
FAh
STOP
P
blink period
1
PSC0
1
+
152
-----------------------
=
=
PWM0
256
-----------------
0.5
=
blink period
max
=
PWM1
256
-----------------
0.25
= AN10397_1
Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Application note
Rev. 01 5 December 2005
5 of 10
Philips Semiconductors
AN10397
How to use the SC18IM700 to control any I
2
C-bus device

3.
SC18IM700: UART to I
2
C-bus controller
The SC18IM700 is designed to serve as an interface between a standard UART of a
microcontroller/microprocessor and the serial I
2
C-bus. This allows the
microcontroller/microprocessor to communicate directly with other I
2
C-bus devices. The
SC18IM700 can operate as an I
2
C-bus master and can be a transmitter or a receiver. The
SC18IM700 controls all the I
2
C-bus specific sequences, protocol, arbitration and timing.
The host communicates with the SC18IM700 with ASCII messages protocol; this makes
the control sequences from host to SC18IM700 become very simple.
The host initiates I
2
C-bus data transfer, read from and write to SC18IM700 internal
registers through a series of ASCII commands. Table 2 lists the ASCII commands
supported by SC18IM700, and also their hex value representation. Unrecognized
commands are ignored by the device.
Please refer to the SC18IM700 data sheet for more descriptive detail of the above
commands.
4.
Using the SC18IM700 to control the PCA9531
The S command can be used to setup the PCA9531s internal registers to blink the LED
at specified frequency and rate. The format for the S command is shown in
Figure 2
.
Table 2:
ASCII commands supported by the SC18IM700
ASCII command
Hex value
Command function
S
0x53
I
2
C-bus START command
P
0x50
I
2
C-bus STOP command
R
0x52
read SC18IM700 internal register command
W
0x57
write to SC18IM700 internal register command
I
0x49
read GPIO port command
O
0x4F
write to GPIO port command
Z
0x5A
power-down
Fig 1.
SC18IM700 controlling the PCA9531
Fig 2.
S command format
UART
002aab967
HOST
UART
SC18IM700
I
2
C-BUS
MASTER
TX
RX
PCA9531
SDA
SCL
NUMBER
OF BYTES
S CHAR.
SLAVE ADR.
+ W
DATA 0
DATA N
P CHAR. AN10397_1
Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Application note
Rev. 01 5 December 2005
6 of 10
Philips Semiconductors
AN10397
How to use the SC18IM700 to control any I
2
C-bus device

The command begins with an S character as the first byte, the second byte specifies the
I
2
C-bus slave address of the I
2
C-bus device, where W is the least significant bit and it is
set to a logic 0. The third byte indicates the number of data bytes in the message (DATA 1
to DATA N), and the last byte ended with the P character.
To turn on and blink the LED, the host would send a message to the SC18IM700 as
follows: S C0 07 11 97 80 00 40 55 FA P.
Once the SC18IM700 receives this message from host it will translate and will send the
same message through the I
2
C-bus to the PCA9531. The LED should be now blinking.
If the host wishes to read the PCA9531 internal registers to make sure they are correctly
set after the host has written to them, the Read after Write command can be used for that
purpose. The format for the Read after Write command is as shown in
Figure 3
.
Using the first example the host sends the following message to the SC18IM700:
S C0 07 11 97 80 00 40 55 FA S C1 07 P
SC18IM will send the message to PCA9531, then will read seven bytes from PCA9531
and sends them to the host automatically. The host will receive the following byte from
SC18IM700 through its UART port:
11 97 80 00 40 55 FA
The host can also ask SC18IM700 to automatically send an I
2
C-bus transaction status
information to the host after SC18IM700 has sent the hosts message to an I
2
C-bus slave.
The host can do this by sending a Register Read command to read the I2Cstatus register
after any normal I
2
C-bus message. Using the above example, the host would send the
following message to SC18IM700:
S C0 07 11 97 80 00 40 55 FA P R 0A P
Once the message is sent to the I
2
C-bus device at address 0xC0, SC18IM700 will send
the I2C_OK (hex code 0xF0) status to the host. See Table 9 of the data sheet for other
I2C Status Code.
Upon receiving the I2C_OK status the host can send another message to SC18IM700.
Fig 3.
Read after Write command format
NUMBER
OF BYTES
S CHAR.
SLAVE ADR.
+ W
DATA 1
DATA N
S CHAR.
NUMBER
OF BYTES
SLAVE
ADR. + R
P CHAR. AN10397_1
Koninklijke Philips Electronics N.V. 2005. All rights reserved.
Application note
Rev. 01 5 December 2005
7 of 10
Philips Semiconductors
AN10397
How to use the SC18IM700 to control any I
2
C-bus device

5.
Using the 8-bit programmable GPIO port
GPIO 0 to GPIO 7 ports may be configured by the host to one of four types. These are:
quasi-bidirectional, push-pull, open-drain, and input-only. Two bits are used to select the
desired configuration for each port pin. PortConf1 is used to select the configuration for
GPIO[3:0], and PortConf2 is used to select the configuration for GPIO[7:4]. Each port pin
has Schmitt triggered input that also has a