AN2352 Cypress, AN2352 Datasheet - Page 4

no-image

AN2352

Manufacturer Part Number
AN2352
Description
I2C USB Bridge Usage
Manufacturer
Cypress
Datasheet
www.DataSheet4U.com
Below is the simple example of I
in a PSoC project:
Code 1. I
extern BYTE
struct I2C_Regs {
} MyI2C_Regs;
void main()
{
WORD wLop;
INT iA;
............
// wX1 access
...........
............
// iADC access
...........
...........
// bStatus access is not need interrupt disable
...........
}
Examples of Bridge Usage During
Testing and Debugging Projects
As was described earlier, the I2C-USB bridge is an ideal
approach to a PC-based data acquisition system. The
collected data can be used to calibrate, rate accuracy,
optimize
Hardware configuration of such a system includes an I2C-
USB bridge, a PC with Windows® 2000\XP installed, and
a communication program (in this design it was
USB2IIC.exe).
Let’s consider how a PC-based data acquisition system
can be used to test and debug projects by examining three
examples. The first example is a tachometer project
(test2_Tach project). This project measures the input
frequency (range 20-20000 Hz) and sends this value to
the PC via the bridge. The input frequency enters through
port pin P0[7] and the I
The Slave_Addr parameter is 0. The command line for the
USB2IIC.exe program, which reads tachometer values, is
as follows:
s 01 xk3 xk2 xk1 xk0 p
9/22/2006
EzI2Cs_SetRamBuffer(5, 2, (BYTE *) &MyI2C_Regs);
M8C_EnableGInt;
EzI2Cs_Start();
M8C_DisableGInt; //!!! turn off interrupt if variable holds more than 1 byte!
if (EzI2Cs_bRAM_RWcntr!=1)wLop=MyI2C_Regs.wX1;
M8C_EnableGInt;
M8C_DisableGInt; //!!! turn off interrupt if variable holds more than 1 byte!
if (EzI2Cs_bRAM_RWcntr!=3) MyI2C_Regs.iADC=iA;
M8C_EnableGInt;
MyI2C_Regs.bStatus=0x20;
WORD wX1;
int iADC;
BYTE bStatus; //
2
C Slave Implementation
device
EzI2Cs_bRAM_RWcntr;
//read/write value
// read only Value
parameters
// turn on interrupt
// turn on interrupt
// Example I2C interface structure
read only Value
2
C interface uses P1[5] and P1[7].
2
and
C slave implementation
prepare
reports.
// Turn on interrupts
// Set up RAM buffer
// Turn on I2C
Revision **
Figure 3 shows a diagram of data collected from the
tachometer.
AN2352
- 4 -

Related parts for AN2352