English
Language : 

TCS3404 Datasheet, PDF (31/40 Pages) TEXAS ADVANCED OPTOELECTRONIC SOLUTIONS – DIGITAL COLOR SENSORS
TCS3404, TCS3414
DIGITAL COLOR SENSORS
APPLICATION INFORMATION: SOFTWARE
TAOS137A − APRIL 2011
The following example pseudo code illustrates the configuration of an SMB-Alert style interrupt when the light
intensity changes 20% from the current value, and persists for 2.5 seconds:
//Assume Interrupt Source as Channel 1
//Read current light level
Address = 0x39
//Slave address − alternatively 0x29 or 0x49
Command = 0xB0
//Set Command bit and SMBus Word read
ReadWord (Address, Command, DataLow, DataHigh)
Channel1 = (256 * DataHigh) + DataLow
//Calculate upper and lower thresholds
T_Upper = Channel1 + (0.2 * Channel1)
T_Lower = Channel1 − (0.2 * Channel1)
//Write the lower threshold register
Command = 0xA8
//Address lower threshold register, set Word Bit
WriteWord (Address, Command, T_Lower.LoByte, T_Lower.HiByte)
//Write the upper threshold register
Command = 0xAA
//Address upper threshold register, set Word bit
WriteWord (Address, Command, T_Upper.LoByte, T_Upper.HiByte)
//Enable interrupt
Command = 0x82
//Address interrupt register
Data = 0x24
//SMBAlert style, Persist 2.5 seconds
WriteByte(Address, Command, Data)
In order to generate an interrupt on demand during system test or debug, a test mode (INTR = 11) can be used.
The following example illustrates how to generate an interrupt on demand:
// Generate an interrupt
Address = 0x39
Command = 0x82
Data = 0x30
WriteByte(Address, Command, Data)
//Slave address alternately 0x29 or 0x49
//Address Interrupt Control Register
//Test interrupt
//Interrupt line should now be low
The LUMENOLOGY r Company
r
r
www.taosinc.com
Copyright E 2011, TAOS Inc.
31