Data Sheet

TCS3404, TCS3414
DIGITAL COLOR SENSORS
TAOS137A − APRIL 2011
31
The LUMENOLOGY r Company
r
r
Copyright E 2011, TAOS Inc.
www.taosinc.com
APPLICATION INFORMATION: SOFTWARE
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 //Slave address alternately 0x29 or 0x49
Command = 0x82 //Address Interrupt Control Register
Data = 0x30 //Test interrupt
WriteByte(Address, Command, Data)
//Interrupt line should now be low