HT3021-10 Ambient Light Sensor with I C Interface 2 Feature Applications • Operating Voltage: 2.7V~5.5V • Backlight control for TFT LCD display • Operating Temperature: -40˚C~85˚C • Contrast enhancement for electronic signboard • Human eye type spectral response with 15-bit effective resolution • Residential and commercial lighting management • Ambient light monitoring for daylight and artificial light • Linear response over full operating range: An output value proportional to ambient light • High dynamic sensing range General Description • Support lighting ripple rejection function for 50Hz/60Hz The HT3021-10 device is an ambient light sensor which provides ambient light measurements with a response similar to the human eye response. The overall operation together with the digital output for this device is implemented using a two-wire I2C serial interface which supports two transfer modes with a frequency of 100kHz and 400kHz respectively. This device is specially designed for applications in which the ambient light measurement is used to control the display backlighting such as laptop computers, PDAs, camcorders, and GPS systems. This device is also suitable for applications which are used as the contrast control in LED signs and displays, camera exposure control, lighting controls, etc. • Support I C interface with two transfer mode: Standard mode (100kHz), Fast mode (400kHz) 2 • Low Power Consumption when operating • Support Power Down Mode • Package Type: SMD Block Diagram Data Register VDD VSS SCL SDA ADRS Photodiode Current Amplifier Integrator & A/D Converter I2C Interface Integration Time Controller Device Address Configuration Internal Oscillator REXT Rev. 1.20 1 July 29, 2014 HT3021-10 Pad Description Pad Name Description Type Serial Data Input/Output pin Serial Data Input/Output for 2-wire I2C interface SDA I/O SCL I Serial Clock Input pin Serial Clock Input for 2-wire I2C interface ADRS I Device Address Select pin This pin can be kept in a high, low or floating state to determine the I2C device address REXT I External Resistor Input This pin is connected to an external resistor when the internal oscillator is used VDD — Positive power supply VSS — Negative power supply, ground Absolute Maximum Ratings Supply Voltage .............................VSS-0.3V~VSS+6.0V Storage Temperature .............................. -40°C~100°C Output Voltage .....................................VSS-0.3V~6.0V Operating Temperature ........................... −40°C~85°C Digital Output Current .......................... -10mA~10mA ESD Tolerance in Human Body Mode (HBM) �����2kV Note: These are stress ratings only. Stresses exceeding the range specified under ″Absolute Maximum Ratings″ may cause substantial damage to the device. Functional operation of this device at other conditions beyond those listed in the specification is not implied and prolonged exposure to extreme conditions may affect device reliability. The ambient thermal resistance must be equal to or less than 50°C/W in applications. Electrical Characteristics Symbol Parameter VDD=3.3V; Ta=25˚C Test Conditions Min. Typ. Max. Unit — 2.7 — 5.5 V VDD Conditions VDD Operating Voltage — IDD Operating Current — — — 0.4 0.5 mA ISTB Standby Current — Power Down Mode — 0.01 0.1 μA VOL Output Low Voltage for SDA — IO=4mA — — 0.4 V Full Scale — — tINT=100ms (note) — 68000 Detection Limit — 32767 count — lux. Note: The tINT means the integration time period. Rev. 1.20 2 July 29, 2014 HT3021-10 Optical Specifications Symbol Ta=25˚C Test Conditions Parameter VDD Conditions — Min. Typ. Max. Unit λP Peak Sensitivity Wavelength 3.3V — 550 — nm RFLU Response to Fluorescent 3.3V EV=100 lux.; tINT=100ms 64 80 96 count RDRK Response in Dark Environment 3.3V EV=0 lux.; tINT=100ms — 0 1 count Note: 1. Fluorescent light is used as light source. White LED is substituted in mass production. 2. The actual photocurrent depends upon the package and optical design. 3. The tINT means the integration time period. D.C. Characteristics of I2C Interface Symbol Parameter Test Condition Standard Mode Fast Mode Min. Max. Min. Max. Unit VDD Operating Voltage — 2.7 5.5 2.7 5.5 VIH Input High Voltage — 2.0 — 2.0 — V VHYS Hysteresis of Schmitt trigger input VDD>2V 0.05×VDD — 0.05×VDD — V VOL Output Low Voltage (Open drain structure) VDD>2V; IOL=3mA 0 0.4 0 0.4 V VNL Noise Margin at Low level Including hysteresis 0.1×VDD — 0.1×VDD — V VNH Noise Margin at High level Including hysteresis 0.2×VDD — 0.2×VDD — V IIN Input current for I/O pins VIN=0.1×VDD~0.9×VDD -10 10 -10 10 μA CIN Capacitance for I/O pins — — 10 — 10 pF CB Capacitive load for each bus line — — 400 — 400 pF Rev. 1.20 3 V July 29, 2014 HT3021-10 A.C. Characteristics of I2C Interface Symbol fSCL Parameter Test Condition Clock frequency — Standard Mode Fast Mode Min. Max. Unit Min. Max. — 100 — 400 kHz 4.7 — 1.3 — μs 4 — 0.6 — μs tBUF Bus Free time Time in which the bus must be free before a new transmission can start tHD: STA Start condition hold time After this period, the first clock pulse is generated tLOW SCL Low time — 4.7 — 1.3 — μs tHIGH SCL High time — 4 — 0.6 — μs tSU: STA Start condition setup time Only relevant for repeated START condition 4.7 — 0.6 — μs tHD: DAT Data hold time — 0 3.45 0 0.9 ns tSU: DAT Data setup time — 250 — 100 — ns ns tR SDA and SCL rise time — — 1000 5 300 tF SDA and SCL fall time — — 300 0.1 300 ns tSU: STO Stop condition set-up time — 4 — 0.6 — μs I2C Interface Timing SDA tBUF tSU:DAT tf tLOW tHD:STA tr SCL tHD:STA S Rev. 1.20 tHD:DAT tHIGH tSU:STA 4 tSU:STO Sr P S July 29, 2014 HT3021-10 Characteristic Curves Integration Time (tINT) vs. External resistor (REXT) Integration Time, tINT (ms) External Resistor REXT (kΩ) Supply Current (IDD) vs. Temperature (˚C) Supply Current, IDD (μA) Temperature (˚C) Rev. 1.20 5 July 29, 2014 HT3021-10 Relative Spectral Response Relative Response (%) Wavelength (nm) Functional Description Integration Mode This device integrates a photodiode to sense the ambient visible light. When the photodiode senses the specific ambient visible light, it will generate certain photocurrent according to the specific wavelength of the ambient light. The photocurrent will be integrated by the internal integrator in a certain integration period of time and then converted to a 15-bit digital output using the A/D converter. The converted digital data is stored in a register word and is read output using the Read Word command via the two-wire I2C interface. The device supports two integration modes; one is the continuous integration mode and the other is the one time integration mode. When this device operates in the continuous integration mode, an external resistor must be connected on the REXT pin to the internal oscillator which provides the integration period of time. However, when the device operates in the one time integration mode, the external resistor is not required. The overall operation is controlled using a two-wire I 2C interface together with the 15-bit digital data readout. This 15-bit data, converted by the transfer method implemented in the device, represents the effective response similar to the dynamic range response of the human eyes. Integration Time When the device is configured to operate in continuous integration mode, the integration period of time is determined by the external resistor connected to the REXT pin together with the internal oscillator. The maximum illumination detection range is inversely proportional to the integration time. That means the higher the illumination detection range is, the shorter the integration time is. REXT resistor (kΩ) Integration Time (ms) Illumination Detection Range (lux.) Resolution (lux./count) 50 50 136000 4.16 100 100 68000 2.08 200 200 34000 1.04 300 300 22000 0.69 400 400 17000 0.52 REXT and Integration Time Example for White LED Rev. 1.20 6 July 29, 2014 HT3021-10 Noise Rejection Device Address Selection The integration period of time must be adjusted to be an integer multiple of the AC noise cycle times to reject the noise with an AC frequency of both 50Hz and 60Hz. To determine a suitable integration period of time, t INT, for both 50Hz and 60Hz power line signals, user can use the following formula: This ambient light sensor is an I 2C slave device of which the device address can be selected using the external address select pin, ADRS. The device address is initially set to 0x39H after power on. The ADRS configuration and the device address selection is shown in the following table. tINT=n×(1/60Hz)=m×(1/50Hz), where n and m are integers →n/m=6/5 ADRS Pin Configuration The first example of these two integers for the tINT integration time to reject the noise of both 50Hz and 60Hz is when n=6 and m=5 respectively. Therefore, the tINT integration time will be 100ms. 0x39H Connected to VDD 0x44H Connected to VSS 0x29H Device Address Selection I2C Serial Interface tINT=6×(1/60Hz)=5×(1/50Hz)=1/10Hz=100ms Referring to the integration time example table, when this device operates in continuous integration mode, the external resistor connected to the REXT pin should be 100kΩ for 100ms integration time to reject the noise with a power line frequency of both 50Hz and 60Hz. When the device operates in one time integration mode, the master device must control the integration time to be an integer multiple of 100ms. I2C Operation The device supports I2C serial interface. The I2C bus is for bidirectional, two-line communication between different ICs or modules. The two lines are a serial data line, SDA, and a serial clock line, SCL. Both lines are connected to the positive power supply via pull-up resistors with a certain value according to different transfer frequency. When the bus is free, both lines are high. Devices connected to the bus must have open-drain or open-collector outputs to implement a wired-or function. Data transfer is initiated only when the bus is not busy. A/D Conversion Data The sensed photocurrent will be integrated and then converted to a 15-bit digital data. The data will be stored in the A/D converter data register pair, ADRH and ADRL. The least significant 8-bit data is stored in the ADRL register while the most significant 7-bit data is stored in the ADRH register. The most significant bit, D15, of the ADRH register is a valid bit which is used to indicate whether the A/D conversion result is available or not. When the A/D conversion result is not ready, the valid bit, D15, will be set to zero. After the A/D conversion is complete, the valid bit will be set to high. The A/D data register pair can be read using the Read Word Command of which the protocol will be described in the corresponding I2C interface section. Note that the MSB of the ADRL register will first be shifted out followed by the ADRH register data when the Read Word Command is executed. ADRH Register Device Address Floating Data validity The data on the SDA line must be stable during the high period of the serial clock. The high or low state of the data line can only change when the clock signal on the SCL line is Low as shown in the diagram. SDA SCL Data line stable; Data valid Change of data allowed ADRL Register Bit 7 Bit 6~0 Bit 7~0 Valid bit Data bit 14~8 Data bit 7~0 A/D Conversion Data Register Rev. 1.20 7 July 29, 2014 HT3021-10 START and STOP conditions Data Output by Transmitter • A high to low transition on the SDA line while SCL is high defines a START condition. not acknowledge Data Output by Receiver • A low to high transition on the SDA line while SCL is high defines a STOP condition. acknowledge SCL From Master • START and STOP conditions are always generated by the master. The bus is considered to be busy after the START condition. The bus is considered to be free again a certain time after the STOP condition. P START condition STOP condition Every byte put on the SDA line must be 8-bit long. The number of bytes that can be transmitted per transfer is unrestricted. Each byte has to be followed by an acknowledge bit. Data is transferred with the most significant bit, MSB, first. SCL S or Sr 1 2 7 8 9 ACK 1 2 3-8 9 ACK clock pulse for acknowledgement Device Address Byte MSB A6 LSB A5 A4 A3 A2 A1 A0 R/W I2C Interface Write Operation P Write Byte Operation Sr A Command Write Byte operation requires a START condition, a slave address with an R/W bit, a command byte and a STOP condition for a command write operation. After the device receives a START bit followed by the device address with an R/W bit equal to 0, the device will compare the received address value and compare it with the internal configured device address. Then the acknowledge signal will be sent by the slave device if the device address is matched after comparison. Therefore, the master device can successively send the command byte to this device and the device will send an acknowledge bit. The master device will then issue a STOP bit after it receives the acknowledge bit sent by the slave device. Note that the communication will be terminated by the master device issuing a STOP condition when an acknowledge bit occurs. P or Sr Acknowledge • Each byte of eight bits is followed by one acknowledge bit. This Acknowledge bit is a low level placed on the bus by the receiver. The master generates an extra acknowledge related clock pulse. • A slave receiver which is addressed must generate an Acknowledge, ACK, after the reception of each byte. • The device that acknowledges must pull down the SDA line during the acknowledge clock pulse so that it remains stable low during the high period of this clock pulse. • A master receiver must signal an end of data to the slave by generating a not-acknowledge, NACK, bit on the last byte that has been clocked out of the slave. In this case, the master receiver must leave the data line high during the 9th pulse to not acknowledge. The master will generate a STOP or repeated START condition. Rev. 1.20 9 • The device address can be 0x39H, 0x44H or 0x29H and selected using the ADRS pin. When an address byte is sent, the device compares the first seven bits after the START condition. If they match, the device outputs an Acknowledge on the SDA line. Byte format SDA 8 • The slave address byte is the first byte received following the START condition form the master device. The first seven bits of the address byte make up the slave address. The eighth bit defines a read or write operation to be performed base on the standpoint of the master device. When the R/W bit is set to 1, then a read operation is selected. A “0” selects a write operation. SCL S 7 Device Addressing SDA SCL S 2 START condition • The bus stays busy if a repeated START (Sr) is generated instead of a STOP condition. In some respects, the START(S) and repeated START (Sr) conditions are functionally identical. SDA 1 Slave Address Command byte R/W S A6 A5 A4 A3 A2 A1 A0 0 Write P BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0 ACK ACK I2C Command Write Byte Operation 8 July 29, 2014 HT3021-10 I2C Interface Read Operation – Read Byte / Read Word Operation Read Byte Operation Read Word Operation A Read Byte operation requires a START condition, a slave address with an R/W bit, a device data byte and a STOP condition for a read byte operation. When the device receives a START bit followed by the device address with an R/W bit equal to 1, the device will compare the received address value and compare it with the internal configured device address. Then the acknowledge signal will be sent by the slave device if the device address is matched after comparison. After the device address compare match occurs, the slave device will send the data byte to the master device. Then the master device will issue a non-acknowledge bit, NACK, followed by a STOP bit to terminate this communication. Note that the communication will be terminated by the master device issuing a STOP condition when a non-acknowledge bit occurs. The data byte sent out by the slave device is the A/D low byte data when operating in active mode. However, the data is the command register content which is written by the master device when operating in communication test mode. A Read Word operation requires a START condition, a slave address with an R/W bit, two A/D data bytes and a STOP condition for a read word operation. When the device receives a START bit followed by the device address with an R/W bit equal to 1, the device will compare the received address value and compare it with the internal configured device address. Then the acknowledge signal will be sent by the slave device if the device address is matched after compared. After the device address compare match occurs, the slave device will first send the A/D low byte data followed by the A/D high byte data each with the MSB being shifted out first to the master device. Then the master device will issue a non-acknowledge bit, NACK, followed by a STOP bit to terminate this communication after it receives a A/D data word. Note that the communication will be terminated by the master device issuing a STOP condition when a non-acknowledge bit occurs. Slave Address Device Data output R/W S A6 A5 A4 A3 A2 A1 1 A0 Read P BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0 ACK NACK I2C Read Byte Operation Slave Address A/D Low Byte Data A/D High Byte Data BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0 BIT7 BIT6 BIT5 BIT4 BIT3 BIT2 BIT1 BIT0 R/W S A6 A5 A4 A3 A2 A1 A0 1 Read ACK ACK Valid bit P NACK I C Read Word Operation 2 Rev. 1.20 9 July 29, 2014 HT3021-10 Device Command Summary There are several commands which are provided to control the overall operation for the ambient light sensor. Refer to the accompanying table for more descriptions. Command Code Command Function 1xxx_xxxx (binary code) Power Down command 0x04H One time integration mode activation command 0x08H One time integration mode START command 0x30H One time integration mode STOP command 0x0CH Continuous integration mode activation command 0x34H Reserved Command Summary Power-Down Command register will have no effect on any operations. In power down mode users can use this command to do the communication test followed by executing the Read Byte operation via the I2C interface. This command is used to power down the device. After power on, the device is initially in this power down status. When the MSB of the command code is set to 1, the device will enter the power down mode and the value written into the internal command Function (MSB) (LSB) Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit7 Bit0 Power Down Command 1 x x x x x x Note Can also be used to test the I2C interface communication. x One Time Integration Mode Activation Command This command is used to activate the one time integration mode. In one time integration mode, the integration time is determined by the one time Function One Time Integration Mode Activation Command integration mode START and STOP command using the I2C interface. (MSB) (LSB) Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit7 Bit0 0 0 0 0 0 1 0 0 Note Integration time is determined by the START/STOP I2C commands. One Time Integration Mode START Command This command is used to START the integration operation when the device is configured to operate in Function One Time Integration Mode START Command Rev. 1.20 one time integration mode. Note that this command is not available in continuous integration mode. (MSB) (LSB) Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit7 Bit0 0 0 0 0 1 0 10 0 0 Note Only available in One Time Integration mode. July 29, 2014 HT3021-10 One Time Integration Mode STOP Command This command is used to STOP the integration operation when the device is configured to operate in one time integration mode. When this STOP command is committed, the valid bit, the MSB of the Function A/D conversion data, will automatically be set to 1. Note that this command is not available in continuous integration mode. (MSB) (LSB) Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit7 Bit0 One Time Integration Mode STOP Command 0 0 1 1 0 0 0 0 Note Only available in One Time Integration mode. Continuous Integration Mode Activation Command This command is used to activate the device to operate in the continuous integration mode. In continuous integration mode, the A/D conversion data register will be updated at the end of each integration Function Continuous Integration Mode Activation Command Rev. 1.20 period of time which is determined by the internal oscillator together with the external resistor connected to the REXT pin. Refer to the integration time section for more details. (MSB) (LSB) Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit7 Bit0 0 0 0 0 1 11 1 0 0 Note Integration time is determined by the internal oscillator together with the external resistor on REXT pin. July 29, 2014 HT3021-10 Programming Sequence Example The procedures of two integration modes are illustrated here with the device address of 0x39H for examples. Continuous Integration mode Power On Issue“Continuous Integration Mode” “Activation Command” Send the device address (0x39H) with R/W=0 and then Send a Command Byte (0x0CH) Issue“Read Word Operation” to Read A/D Conversion Data Send the device address (0x39H) with R/W=1 and then wait for two bytes A/D data The A/D low byte data is first shifted out followed by the A/D high byte data with MSB shifted first. Read A/D Low Byte Data & A/D High Byte Data No The MSB of the A/D high byte data is the valid bit. For the first A/D conversion, if the valid bit is 0, it means that the conversion is not complete after being activated. Valid Bit = 1 ? After the first A/D conversion, the valid bit is equal to 1, the A/D data is available, The A/D data will not be updated until the next conversion is finished. Yes A/D Conversion Data is available Note that the valid bit will be“1”before the next conversion is finished. A/D Conversion Terminated? No Continue to Perform the integration and A/D conversion for next integration time period. Yes Issue “Power down”Command Send the device address (0x39H) with R/W=0 and then Send a Command Byte (0x8CH) Power Down Rev. 1.20 12 July 29, 2014 HT3021-10 One Time Integration mode Power On Issue“One Time Integration Mode” “Activation Command” Send the device address (0x39H) with R/W=0 and then Send a Command Byte (0x04H) Issue“One Time Integration Mode” “START Command” Send the device address (0x39H) with R/W=0 and then Send a START Command Byte (0x08H) An enough period of delay is necessary for A/D integration. Issue“One Time Integration Mode” “STOP Command” Send the device address (0x39H) with R/W=0 and then Send a STOP Command Byte (0x30H) Issue“Read Word Operation” to Read A/D Conversion Data” Send the device address (0x39H) with R/W=1 and then wait for two bytes A/D conversion data Read A/D Low Byte Data & Read A/D High Byte Data No Valid Bit = 1 ? The A/D low byte data is first shifted out followed by the A/D high byte data with MSB shifted first. The MSB of the A/D high byte data is the valid bit. If the valid bit is 0, the STOP command may not be is received by the device when the integration time of period is enough. Yes A/D Conversion Data is available Send the device address (0x39H) with R/W=0 and then Send a Command Byte (0x8CH) Issue “Power down”Command Power Down Rev. 1.20 13 July 29, 2014 HT3021-10 Hardware Design Example Flat Window Lens Design The window lens will limit the viewing angle of this device. The window lens should be placed directly on the top of the device. The lens thickness should be kept at a minimum value to minimize the power loss due to the reflection together with the energy absorbed in the plastic material. A thickness with a value of 1mm is recommended for a window lens design. The larger the window lens diameter, the wider the device viewing angle is. The recommended optical window dimensions are listed in the table to ensure both 35° and 45° viewing angle. These dimensions are based on a window lens thickness of 1mm and a refractive index of 1.59. Window Lens t DTOTAL θ: viewing angle θ D1 HT3021-10 DLENS Flat Window Lens DTOTAL D1 DLENS @35° Viewing Angle 1.5 0.5 2.25 DLENS @45° Viewing Angle 3.75 2.0 1.0 3.00 4.75 2.5 1.5 3.75 5.75 3.0 2.0 4.30 6.75 3.5 2.5 5.00 7.75 Note: All dimensions are in the unit of millimeter (mm). Recommended Dimensions for Flat Window Lens Design (t=1mm) Window with Light Pipe Design D1 of a value equal to 0.5mm to achieve a better performance. The light pipe should have a minimum diameter of 1.5mm to ensure that the whole area of the sensor will be exposed. With the same effective device viewing angle, if a smaller window is desired, a cylindrical transparent plastic pipe is necessary to trap and focus the light and then guide the light on the device. The pipe should be directly places on the top of the device with a distance DLENS D2 D2 > 1.5mm L Light Pipe D2 Window Lens D1 DLENS t HT3021-10 Window with Light Pipe Rev. 1.20 14 July 29, 2014 HT3021-10 Application Circuit VDD VDD 4.7uF 0.1uF VDD SCL SDA REXT CEXT VSS 100pF REXT 100KΩ VSS VSS Note: 1. The REXT resistor is not required when the device operates in one time integration mode. 2. The CEXT capacitor is optional for long distance connection when the device operates in continuous integration mode. Rev. 1.20 15 July 29, 2014 HT3021-10 Other Considerations Reliability Test Conditions Items Temperature Cycling Test Test Conditions Temp.=-30˚C~85˚C (100min.) (30min.) (100min.) Hour or Cycle Sample No. Failure No. 100 cycles 30 0 High Temperature & Humidity Storage Temp.=85˚C, 85%RH 500 hours 30 0 Low Temperature Operation Life Temp.=-30˚C, VDD=3V 500 hours 30 0 High Temperature Operation Life Temp.=85˚C, VDD=3V 500 hours 30 0 High Temperature Storage Temp.=85˚C 500 hours 30 0 IR Reflow 170˚C→235˚C→275˚C→180˚C 5 cycles 500 0 Recommended Storage Method Recommended Solder Profile It is recommended to store the reels in the dry box once the aluminum bag, which is used to prevent the moisture absorption, has been opened. The following conditions, which can achieve the moisture prevention level 3, should be observed if the dry boxes are not available. • Storage Temperature: 10˚C~30˚C • Storage Humidity ≤ 60%RH (max.) • Storage Time ≤ 168 hours (max.) Reflow Soldering If there is moisture absorbed by the device, it is recommended to recover the device to the original condition using one of the accompanying recommended drying methods. Note: 1. Reflow soldering should not be done more than two times. 2. When soldering, do not put stress on the ALS devices during heating. 3. After soldering, do not warp the circuit board. • 192 hours at 40˚C+ 5˚C/ -0˚C and 5% RH (dry air / nitrogen) Necessary Soldering Correction Manually • 96 hours at 60˚C+ 5˚C and < 5% RH for all device containers Temperature: No more than 350˚C (25W for soldering iron). • 24 hours at 125˚C+ 5˚C and not suitable for reel or tubes Time: Within 5 seconds. ESD Precaution Note: Do not do this more than once for any given pin. Proper storage and handing procedures should be followed to prevent ESD damage to the devices especially when they are removed from the anti-static bag. Electro-Static Sensitive devices warning labels are on the packing. Rev. 1.20 16 July 29, 2014 HT3021-10 Sample Code in C for 8051 . //********** HT3021-10 #include <reg51.h> #include <intrins.h> READOUT Sample Code ***********// #define WR3021 0x72 #define RD3021 0x73 //********************/ sbit SDA=P3^6; sbit SCL=P3^7; sbit SPK=P3^4; unsigned char COMMAND=0xFF; void Delay400Ms(void); void Delay100Ms(void); void I2C_start(void); void I2C_stop(void); void I2C_ACK(bit tmp); unsigned char I2C_read(); void I2C_write(unsigned char tmp); //*** Power Down Mode ***// COMMAND=0xff; I2C_start(); I2C_write(WR3021); I2C_ACK(1); I2C_write(COMMAND); I2C_ACK(1); I2C_stop(); //*** Continuous Integration Mode ***// COMMAND=0x0C; I2C_start(); I2C_write(WR3021); I2C_ACK(1); I2C_write(COMMAND); I2C_ACK(1); I2C_stop(); Delay400Ms(); //*** One Time Integration Mode 400ms ***// COMMAND=0x04; I2C_start(); I2C_write(WR3021); I2C_ACK(1); I2C_write(COMMAND); I2C_stop(); COMMAND=0x08; I2C_start(); I2C_write(WR3021); I2C_ACK(1); I2C_write(COMMAND); I2C_ACK(1); Rev. 1.20 17 July 29, 2014 HT3021-10 I2C_stop(); Delay400Ms(); COMMAND=0x30; I2C_start(); I2C_write(WR3021); I2C_ACK(1); I2C_write(COMMAND); I2C_ACK(1); I2C_stop(); //*** One Time Integration Mode 100ms ***// COMMAND=0x04; I2C_start(); I2C_write(WR3021); I2C_ACK(1); I2C_write(COMMAND); I2C_ACK(1); I2C_stop(); COMMAND=0x08; I2C_start(); I2C_write(WR3021); I2C_ACK(1); I2C_write(COMMAND); I2C_ACK(1); I2C_stop(); Delay100Ms(); COMMAND=0x30; I2C_start(); I2C_write(WR3021); I2C_ACK(1); I2C_write(COMMAND); I2C_ACK(1); I2C_stop(); //Read Data// tmp=tmp2=0; I2C_start(); I2C_write(RD3021); I2C_ACK(1); tmp=I2C_read(); I2C_ACK(0); tmp2=I2C_read(); I2C_stop(); void Delay400Ms(void) { unsigned char TempCycA=5; unsigned int TempCycB; while(TempCycA--) { TempCycB=7269; while(TempCycB--); }; } Rev. 1.20 18 July 29, 2014 HT3021-10 void Delay100Ms(void) { unsigned char TempCycA=5; unsigned int TempCycB; while(TempCycA--) { //TempCycB=3635; TempCycB=1817; while(TempCycB--); }; } void I2C_start(void) { SDA=1; _nop_(); SCL=1; _nop_(); SDA=0; _nop_(); SCL=0; _nop_(); } void I2C_stop(void) { SDA=0; _nop_(); SCL=1; _nop_(); SDA=1; _nop_(); SCL=0; _nop_(); SCL=1; } void I2C_ACK(bit tmp) { SDA=tmp; _nop_();_nop_();_nop_();_nop_();_nop_(); SCL=1; _nop_();_nop_();_nop_();_nop_();_nop_(); SCL=0; } unsigned char I2C_read(void) { unsigned char i,tmp; tmp=0; for(i=0;i<8;i++) { SCL=0; _nop_(); _nop_(); _nop_(); SDA=1; _nop_();_nop_();_nop_();_nop_();_nop_(); Rev. 1.20 19 July 29, 2014 HT3021-10 SCL=1; _nop_();_nop_();_nop_();_nop_();_nop_(); tmp<<=1; if(SDA==1) tmp++; } SCL=0; return tmp; } void I2C_write(unsigned char tmp) { unsigned char i; for(i=0;i<8;i++) { SCL=0; _nop_(); _nop_(); _nop_(); SDA=(bit)(tmp&0x80); tmp<<=1; _nop_();_nop_();_nop_();_nop_();_nop_(); SCL=1; _nop_();_nop_();_nop_();_nop_();_nop_(); } SCL=0; } Rev. 1.20 20 July 29, 2014 HT3021-10 Package Type: SMD Top View Bottom View Side View Pad No. Pad Name 1 SCL 2 VDD 3 REXT 4 ADRS 5 VSS 6 SDA Pad Assignment Note: 1. Dimension unit: mm. 2. All tolerances are limited to ±0.1mm unless otherwise noted. Rev. 1.20 21 July 29, 2014 HT3021-10 Tape Specifications Tape Arrangement Tape Dimension (unit: mm) Reel Dimension (unit: mm) Feeding Direction Note: 1. Empty component pockets are sealed with top cover tape 2. The maximum number of missing lamps is two 3. The Polarity is oriented towards the tape sprocket hole 4. 3000 pcs./Reel Rev. 1.20 22 July 29, 2014 HT3021-10 Packaging Specifications Reel (3000 pcs.) Label Moisture-proof bag Label Inside box Label Maximum seven reels Label Outside box Maximum four inside boxes Note: Reeled products (numbers of products are 3000 pcs.) packed in a seal off moisture-proof bag along with a desiccant one by one, Seven moisture-proof bag of maximums (total maximum number of products 21000 pcs.) packed in an inside box (size: about 238mm×about 194mm×about 102mm) and four inside boxes of maximum are put in the outside box (size: about 410mm×about 254mm×about 229mm) Together with buffer material, and it is packed. (Part No., Lot No., Quantity should appear on the label on the moisture-proof bag, Part No. and Quantity should appear on the label on the cardboard box.) The number of the loading steps of outside box (cardboard box) has it to three steps. Rev. 1.20 23 July 29, 2014 HT3021-10 Copyright© 2014 by HOLTEK SEMICONDUCTOR INC. The information appearing in this Data Sheet is believed to be accurate at the time of publication. However, Holtek assumes no responsibility arising from the use of the specifications described. The applications mentioned herein are used solely for the purpose of illustration and Holtek makes no warranty or representation that such applications will be suitable without further modification, nor recommends the use of its products for application that may present a risk to human life due to malfunction or otherwise. Holtek's products are not authorized for use as critical components in life support devices or systems. Holtek reserves the right to alter its products without prior notification. For the most up-to-date information, please visit our web site at http://www.holtek.com.tw. Rev. 1.20 24 July 29, 2014