AN2352 Cypress, AN2352 Datasheet - Page 7

no-image

AN2352

Manufacturer Part Number
AN2352
Description
I2C USB Bridge Usage
Manufacturer
Cypress
Datasheet
www.DataSheet4U.com
IO Expander Usage with Bridge
A good example of I2C-USB bridge implementation is
usage of the Cypress IO port expander, CY8C9520.
Command line examples using USB2IIC.exe, for working
with the 20-pin IO expander, are described below.
The CY8C9520 expander has 20 pins, which can be
separately configured to several modes. The command
string below shows how pins on IO expander port 0 can be
configured (Table 1). Register 0x18 selects which
expander port is to be configured.
s 42 18 00 S 42 19 9F 00 CD 71 04 02 10 80 01 48
20
Table 1. Pin Configuration of Expander Port 1
The state of expander inputs can be read from registers
with 0..2 address:
s 42 00 s 43 x x x p
The pins’ output data are controlled by registers that have
0x08..0x0A address. The following example turns to zero
all outputs of port 0 and turns to 1 all outputs of port 1:
s 42 08 00 FF p
9/22/2006
19
1A
1B
1C
1D
1E
1F
20
21
22
23
Register
9F
00
CD
71
04
02
10
80
01
48
20
Value
Interrupt Mask Register
PWM Output Register
Inversion Register
Input/Output Register
Pull Up Drive Mode Pins
Pull Down Drive Mode Pins
Open Drain High Drive Mode Pins
Open Drain Low Drive Mode Pins
Strong Drive Mode Pins
Strong Slow Drive Mode Pins
High Z Drive Mode Pins
Description
Revision **
The Interrupt Status registers can be read to detect
expander input activity. This feature is very useful for
counting quantity of certain physical values such as water,
gas or electricity. The Interrupt Status registers start at
register 0x10. Below is a command string that reads the
interrupt status from all three expander ports:
s 42 10 s 43 x x x p
Remember that the Interrupt Status register is updated
each time an activity on the input pin is present and
Interrupt Mask bit of the pin is set to 0 (register 0x19).
The CY8C9520 expander also has several PWM blocks,
which output can be directed to the output pins. The
frequency range for the PWMs is from 12 MHz to
0.0000001 Hz. They can be used for transforming a digital
signal to a pulse-duration analog signal, or even as a low-
speed DAC with high-resistance output. The example
below shows the initialization strings, which turn the
PWM1 to a frequency of 3.5 Hz with 50% duty cycle. The
output of the PWM is sent to pin 24 of the expander
(Port1[3]):
s 42 18 01 s 42 1A 08 p
s 42 21 01 s 42 1A 08 p //set pin mode
s 42 28 00 S 42 29 04 68 34 p //set PWM1
parameters
Moreover, the CY8C9520 expander has built-in EEPROM,
which is available for use with I
EEPROM, use the following string:
s 42 2D 43 4d 53 02 p
Once this command string executes, EEPROM is available
at address 0x80+Expander Address, or 0xA2, in this case.
Let’s write 8 bytes to EEPROM address of 0x0020:
s A2 00 20 00 11 22 33 44 55 66 77 p
Now, we will read 4 bytes from address 0x0024:
sA2 00 24 s A3 x x x x p
//set PWM pin
2
C master. To enable
AN2352
- 7 -

Related parts for AN2352