Part Number Hot Search : 
SXXXFF UPD75 202062 W25X2 CXXXE AT80C5 GBJ5006 TOP234Y
Product Description
Full Text Search
 

To Download AN2335 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  october 2006 rev 2 1/40 AN2335 application note lis302dl: 3-axis - 2g/8g digital output ultracompact linear accelerometer introduction this document is intended to give application notes for the low-voltage 3-axis digital output linear mems accelerometer provided in lga package. the lis302dl is an ultra compact low-power three axes linear accelerometer that includes a sensing element and an ic interface able to take the information from the sensing element and to provide the measured acceleration to the external world through i 2 c/spi serial interface. the sensing element, capable of detecting the acceleration, is manufactured using a dedicated process develo ped by st to produce inertial sensors and actuators in silicon. the ic interface instead is manufactured using a cmos process that allows high level of integration to design a dedicated circuit which is factory trimmed to better match the sensing element characteristics. the lis302dl has a user selectable full scale of 2g, 8g and it is capable of measuring accelerations with an output data rate of 100hz or 400hz. a self-test capab ility allows the user to check the correct operation of the system. the device features two independent highly programmable interrupt sources that can be configured either to generate an inertial wake-up interrupt signal when a programmable acceleration threshold is exceeded along one of the three axes or to detect a free-fall event. two independent pins can be configured to provide interrupt signals to connected devices. the lis302dl is available in plastic smd package and it is specified over a temperature range extending from -40c to +85c. the ultra small size and weight of this package make it an ideal choice for handheld portable applications such as cell phones and pdas or any other application where reduced package size and weight are required. www.st.com
contents AN2335 2/40 contents 1 theory of operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2 electrical connection and board layout hints . . . . . . . . . . . . . . . . . . . . . 7 2.1 electrical connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.2 soldering information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 3 absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 4 digital interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.1 i2c bus interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 4.1.1 i2c operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 4.1.2 i2c subsequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 4.2 spi bus interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.2.1 read & write protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.2.2 spi read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4.2.3 spi write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4.2.4 spi read in 3-wires mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 5 registers description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 5.1 registers address map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 5.1.1 reserved registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 5.1.2 registers loaded at boot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 6 about control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6.1 ctrl_reg1 (20h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 6.2 ctrl_reg2 (21h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 6.3 ctrl_reg3 (22h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 7 data and status registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 7.1 who_am_i (0fh) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 7.2 status_reg (27h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 7.3 outx (29h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 7.4 outy (2bh) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
AN2335 contents 3/40 7.5 outz (2dh) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 8 free-fall and wake-up r egisters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 8.1 hp_filter_reset (23h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 8.2 ff_wu_cfg_1 (30h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 8.3 ff_wu_src_1 (31h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 8.4 ff_wu_ths_1 (32h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 8.5 ff_wu_duration_1 (33h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 8.6 ff_wu_cfg_2 (34h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 8.7 ff_wu_src_2 (35h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 8.8 ff_wu_ths_2 (36h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 8.9 ff_wu_duration_2 (37h) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 9 application information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 9.1 start-up sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 9.2 reading acceleration data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 9.2.1 using the status register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 9.2.2 using the data-ready signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 9.3 understanding acceleration data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 9.4 interrupt generation description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 9.5 inertial wake-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 9.5.1 hp filter bypassed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 9.5.2 using the hp filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 9.6 free-fall detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 9.6.1 roll function not used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 9.6.2 roll function applied . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 9.7 output data rate selection and reading timing . . . . . . . . . . . . . . . . . . . . . 37 9.8 data ready vs. interrupt signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 10 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
list of tables AN2335 4/40 list of tables table 1. absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 table 2. serial interface pin description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 table 3. terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 table 4. registers address map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 table 5. output data registers content vs. acceleration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 table 6. output data rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 table 7. timing value to avoid loosing the data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 table 8. document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
AN2335 list of figures 5/40 list of figures figure 1. device block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 figure 2. lis302dl electrical connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 figure 3. i2c subsequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 figure 4. read & write protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 figure 5. spi read protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 figure 6. multiple bytes spi read protocol (2 bytes example) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 figure 7. spi write protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 figure 8. multiple bytes spi write protocol (2 bytes example) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 figure 9. spi read protocol in 3-wires mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 figure 10. digital processing chain block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 figure 11. ff_wu_cfg_1,2 high and low value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 figure 12. dcrm bit function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 figure 13. interrupt generation block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 figure 14. free-fall, wake-up interrupt generator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3 figure 15. reading timing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 figure 16. interrupt and dataready signal generation block diagram. . . . . . . . . . . . . . . . . . . . . . . . . . 38 figure 17. data ready signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
theory of operation AN2335 6/40 1 theory of operation the lis302dl is an ultracompact, low-power, digital output 3-axis linear accelerometer packaged in a lga package. the complete device includes a sensing element and an ic interface able to take the information from the sensing element and to provide a signal to the external world through an i 2 c/spi serial interface ( figure 1 ). a proprietary process is used to create a surface micro-machined accelerometer. the technology allows to carry out suspended s ilicon structures which are attached to the substrate in a few points called anchors and are free to move in the direction of the sensed acceleration. to be compatible with the traditional packaging techniques a cap is placed on top of the sensing element to avoid blocking the moving parts during the moulding phase of the plastic encapsulation. when an acceleration is applied to the sensor the proof mass displaces from its nominal position, causing an imbalance in the capacit ive half-bridge. this imbalance is measured using charge integration in response to a voltage pulse applied to the sense capacitor. at steady state the nominal value of the capacitors are few pico farad and when an acceleration is applied the maximum variation of the capacitive load is of few femto farad. the complete measurement chain is composed by a low-noise capacitive amplifier which converts into an analog voltage the capacitive unbalancing of the mems sensor and by and by analog-to-digital converters. the acceleration data may be accessed through an i 2 c/spi interface thus making the device particularly suitable for direct interfacing with a microcontroller. data synchronization in digital system employing the device is made simpler through the usage of the data-ready signal (rdy) whic h indicates when a new set of measured acceleration data is available thus simplifyi ng data synchronization in digital system employing the device itself. the lis302dl features also two independent fully programmable interrupt sources which can be programmed to generate an interrupt signal when a programmable acceleration threshold is exceeded along one of the three axes or to detect a free-fall event. the ic interface is factory calibrated for sensitivity (so) and zero-g level (off). the trimming values are stored inside the device by a non volatile structure. any time the device is turned on, the trimming parameters are downloaded into the registers to be employed during the normal operation. this allows the user to employ the device without further calibration. figure 1. device block diagram charge amplifier mux y+ z+ y- z- a x+ x- i 2 c spi cs scl/spc sda/sdo/sdi sdo control logic & interrupt gen. int 1 clock trimming circuits reference self test control logic a/d converter int 2
AN2335 electrical connection and board layout hints 7/40 2 electrical connection a nd board layout hints 2.1 electrical connection the typical electrical connection of the lis302dl is shown in figure 2 figure 2. lis302dl electrical connection the lis302dl is designed to operate with a voltage supply spanning from 2.16v up to 3.6v while the serial interface can work down to 1.8v. the device core is supplied through vdd line (vdd typ=2.5v) while the i/o pads are supplied through vdd_io line. the typical current consumption in normal mode at 2.5v is 400 a. both the voltage supplies must be present at the same time to have proper behavior of the ic. it is possible to remove vdd mantaining vdd_io without blocking the communication bus. adequate power supply decoupling is required to ensure ic performances. the optimum decoupling is achieved by using two capacitors of different types that target different kinds of noise on the power supply leads. to attenuate high frequency transients, spikes, or digital hash on the line it is recommended the use of one 100nf ceramic or polyester capacitor which must be placed as close as possible to device vdd lead. for filtering lower-frequency noise signals, a larger aluminum capacitor of 10 f or greater should be placed near the device in parallel to the former capacitor. it is recommended to place these capacitors as near as possible to the pin 6 of the device. the functionality of the device and the measured acceleration data are selectable and accessible through the i 2 c/spi interface. when using the i 2 c, cs must be tied high while sdo allows to select among two device addresses in case two sensors must be connected on the same bus. whenever one single sensor is present on the same i 2 c bus it is recommended either to connect sdo to vdd_io or to leave it floating. 6 8 13 1 top view cs 10uf vdd 100nf gnd vdd_io sdo sda/sdi/sdo int1 int2 scl/spc digital signal from/to signal controller.signal?s levels are defined by proper selection of vdd_io 1 13 8 6 top view x z y direction of the detectable accelerations
absolute maximum ratings AN2335 8/40 2.2 soldering information the lga-14 package is lead free and green package qualified for soldering heat resistance according to jedec j-std-020c. land pattern and soldering recommendations are available upon request. 3 absolute maximum ratings stresses above those listed as ?absolute ma ximum ratings? may cause permanent damage to the device. this is a stress rating only and functional operation of the device under these conditions is not implied. exposure to maximum rating conditions for extended periods may affect device reliability. warning: this is a esd sensitive device, improper handling can cause permanent damages to the part. warning: this is a mechanical shock sensitive device, improper handling can cause permanent damages to the part. table 1. absolute maximum ratings symbol ratings maximum value unit vdd supply voltage (1) 1. supply voltage on any pin should never exceed 6.0v -0.3 to 6 v vdd_io i/o pins supply voltage (1) -0.3 to 6 v vin input voltage on any control pin (cs, scl/spc, sda/sdi/sdo, ck) -0.3 to vdd_io +0.3 v a pow acceleration (any axis, powered, vdd=2.5v) 3000g for 0.5 ms 10000g for 0.1 ms a unp acceleration (any axis, unpowered) 3000g for 0.5 ms 10000g for 0.1 ms t op operating temperature range -40 to +85 c t stg storage temperature range -40 to +125 c esd electrostatic discharge prot ection class 1: 0 - 2kv hbm
AN2335 digital interfaces 9/40 4 digital interfaces the registers embedded inside the lis302dl may be accessed through i 2 c and spi serial interfaces. the latter may be sw configured to operate either in 3-wire or 4-wire interface mode. the serial interfaces are mapped onto the same pads. to select/exploit the i 2 c interface, cs line must be tied high (i.e connected to vdd_io). 4.1 i 2 c bus interface the lis302dl i 2 c is a bus slave. the i 2 c is employed to write/read the data into/from the registers. the relevant i 2 c terminology is shown in ta b l e 3 : there are two signals associated with the i 2 c bus: the serial clock line (scl) and the serial data line (sda). the latter is a bidirectional line used for sending and receiving the data to/from the interface. both the lines are connected to vdd_io through a pull-up resistor embedded inside the lis302dl. when the bus is free both the lines are high. the i 2 c interface is compliant wit h fast mode (400 khz) i 2 c standards as well as the normal mode. table 2. serial interface pin description pin name pin description cs spi chip select (cs) i 2 c/spi selector (1: i 2 c mode; 0: spi enabled) scl/spc spi ck line (scl) i 2 c clock line (spc) sdi/sda/sdo i 2 c serial data (sda) spi data in (sdi) spi data out (sdo) -for 3-wire spi mode- sdo i 2 c less significant bit of device address spi data out (sdo) -for 4-wire spi mode- table 3. terminology term description transmitter the device which sends data to the bus receiver the device which receives data from the bus master the device which initiates a transfer, generates clock signals and terminates a transfer slave the device addressed by the master
digital interfaces AN2335 10/40 4.1.1 i 2 c operation the transaction on the bus is started through a start (st) condition which is defined as a high to low transition on the data line while the scl line is held high. after the start condition has been generated by the master, the bus is considered busy. the next byte of data transmitted contains the address of the slav e in the first 7 bits and the eighth bit tells whether the master is receiving data from the slave or transmitting data to the slave (sad subsequence). when an address is sent, each device in the system compares the first seven bits after a start condition with its own address. if they match, the device considers itself addressed by the master. the slave address (sad) associated to the lis302dl may be selected among the two predefined values 0011100b or 0011101b depending on the logic level present on sdo pin. in details, if sdo pin is either connected to v dd_io or left unconnected the slave address is 0011101b, otherwise when it is connected to gnd the slave address is 0011100b. whenever it is not needed to place two sensors on the same bus it is recommended to use the slave address 0011101b by either connecting the sdo pin to vdd_io or leaving it floating. data transfer with acknowledge is mandatory. the transmitter must release the sda line during the acknowledge pulse. the receiver must then pull the data line low so that it remains stable low during the high period of the acknowledge clock pulse. a receiver which has been addressed is obliged to generate an acknowledge after each byte of data has been received. the i 2 c embedded inside the lis302dl behaves like a slave device and the following protocol must be adhered to. after the start condition (st) a salve address is sent, once a slave acknowledge (sak) has bee n returned, a 8-bit sub-addre ss will be transmitted: the 7 lsb represent the actual register address while the msb enables address auto increment. if the msb of the sub field is 1, the sub (regis ter address) will be auto matically incremented to allow multiple data read/writ e. otherwise if the msb of th e sub field is ?0?, the sub will remain unchanged and multiple read/write on the same address can be performed. the slave address is completed with a read/write bit. if the bit was ?1? (read), a repeated start (sr) condition will have to be issued after the two sub-addr ess bytes; if the bit is ?0? (write) the master will transmit to the slave with di rection unchanged. transfer when master is writing one byte to slave transfer when master is writing multiple bytes to slave: transfer when master is receiving (reading) one byte of data from slave: master st sad + w sub data sp slave sak sak sak master st sad + w sub data data sp slave sak sak sak sak master st sad + w sub sr sad + r nmak sp slave sak sak sak data
AN2335 digital interfaces 11/40 transfer when master is receiving (reading) multiple bytes of data from slave data are transmitted in byte format (data). each data transfer contains 8 bits. the number of bytes transferred per transfer is unlimited. data is transferred with the most significant bit (msb) first. if a receiver can?t receive another complete byte of data until it has performed some other function, it can hold the clock line, scl low to force the transmitter into a wait state. data transfer only continues when the receiver is ready for another byte and releases the data line. if a slave receiver doesn?t acknowledge the slave address (i.e. it is not able to receive because it is performing some real time function) the data line must be left high by the slave. the master can then abort the transfer. a low to high transition on the sda line while the scl line is high is defined as a stop condition. each data transfer must be terminated by the generation of a stop (sp) condition. in order to read multiple bytes, it is necessary to assert the most significant bit of the sub- address field. in other words, sub(7) must be equal to 1 while sub(6-0) represents the address of first register to read. in the presented communication format mak is master acknowledge and nmak is no master acknowledge. 4.1.2 i 2 c subsequences in order to better define subsequences and to clarify line scl and sda behavior, a description containing discrete value of scl and sda will follow. in column there is the value present on line scl and sda in discrete timing. these simple subsequences are used to realize complex commands described in the following paragraph. master st sad + w sub sr sad + r mak slave sak sak sak data master mak nmak sp s l a ve data data
digital interfaces AN2335 12/40 figure 3. i 2 c subsequences st: start condition scl 1111 sda 1100 sr: repeated start condition scl 1111 sda 1100 sad: slave address (binary address: abcdefgh. in lis302dl ?abcdef? = ?001110?) scl 00110 0110 0110 0110 0110 0110 0110 0110 sda 0aaaa bbbb cccc dddd eeee f f f f gggg hhhh bit g=0 if sdo connected to gnd, g=1 if sdo pad connected to vdd bit h=0 => write, h=1 => read sak: slave acknowledge (z means high impedance) scl 0011 sda (force) zzzz check that sda is 0 after scl=1 sda (read) xx00 sub: sub address (binary address: a0cdefgh) scl 00110 0110 0110 0110 0110 0110 0110 0110 sda 0aaaa 0000 cccc dddd eeee f f f f gggg hhhh bit a=0 => do not increment address in multiple mode a=1 => increment address in multiple mode data (master): send data byte (binary number: abcdefgh) scl 00110 0110 0110 0110 0110 0110 0110 0110 sda 0aaaa bbbb cccc dddd eeee f f f f gggg hhhh data (slave): read data byte (binary number: abcdefgh) scl 00110 0110 0110 0110 0110 0110 0110 0110 sda (force) zzzz zzzz zzzz zzzz zzzz zzzz zzzz zzzz sda (read) a b c d e f g h sp: stop condition scl 1111 sda 0011 mak: master acknowledge scl 0011 sda 0000 nmak: no master acknowledge scl 0011 sda zzzz or 1111
AN2335 digital interfaces 13/40 4.2 spi bus interface the lis302dl spi is a bus slave. the spi allows to write and read the registers of the device. the serial interface interacts with the outside world with 4 wires: cs , spc , spdi and spdo . 4.2.1 read & write protocol figure 4. read & write protocol cs is the chip select and it is controlled by the spi master. it goes low at the start of the transmission and goes back high at the end. spc is the serial port clock and it is controlled by the spi master. it is stopped high when cs is high (no transmission). sdi and sdo are respectively the serial port data input and ou tput. those lines are driven at the falling edge of spc and should be captured at the rising edge of spc . both the read register and write register commands are completed in 16 clocks pulses or in multiple of 8 in case of mu ltiple byte read/write. bit durati on is the time between two falling edges of spc . the first bit (bit 0) starts at the firs t falling edge of spc after the falling edge of cs while the last bit (bit 15, bit 23, ...) starts at the last falling edge of spc just before the rising edge of cs . bit 0 : rw bit. when 0, the data di(7:0) is written into the device. when 1, the data do(7:0) from the device is read. in latter case, the chip will drive sdo at the start of bit 8. bit 1 : ms bit. when 0, the address will remain unch anged in multiple r ead/write commands. when 1, the address will be auto increment ed in multiple r ead/write commands. bit 2-7 : address ad(5:0). this is the address field of the indexed register. bit 8-15 : data di(7:0) (wri te mode). this is the data that will be written into the device (msb first). bit 8-15 : data do(7:0) (read mode). this is the da ta that will be read from the device (msb first). in multiple read/write comman ds further blocks of 8 clock per iods will be added. when ms bit is 0 the address used to read/write data remains the same for every block. when ms bit is 1 the address used to read/write data is incremented at every block. the function and the behavior of sdi and sdo remain unchanged. cs spc sdi sdo rw ad5 ad4 ad3 ad2 ad1 ad0 di7 di6 di5 di4 di3 di2 di1 di0 do7 do6 do5 do4 do3 do2 do1 do0 ms
digital interfaces AN2335 14/40 4.2.2 spi read figure 5. spi read protocol the spi read command is performed with 16 clocks pulses. multiple byte read command is performed adding blocks of 8 clocks pulses at the previous one. bit 0 : read bit. the value is 1. bit 1 : ms bit. when 0 do not increment address, when 1 increment address in multiple reading. bit 2-7 : address ad(5:0). this is the address field of the indexed register. bit 8-15 : data do(7:0) (read mode). this is the da ta that will be read from the device (msb first). bit 16-... : data do(...-8). further da ta in multiple byte reading. figure 6. multiple bytes spi read protocol (2 bytes example) 4.2.3 spi write figure 7. spi write protocol cs spc sdi sdo rw do7 do6 do5 do4 do3 do2 do1 do0 ad5 ad4 ad3 ad2 ad1 ad0 ms cs spc sdi sdo rw do7 do6 do5 do4 do3 do2 do1 do0 ad5 ad4 ad3 ad2 ad1 ad0 do15 do14 do13 do12 do11 do10 do9 do8 ms cs spc sdi rw di7 di6 di5 di4 di3 di2 di1 di0 ad5 ad4 ad3 ad2 ad1 ad0 ms
AN2335 digital interfaces 15/40 the spi write command is performed with 16 clocks pulses. multiple byte write command is performed adding blocks of 8 clocks pulses at the previous one. bit 0 : write bit. the value is 0. bit 1 : ms bit. when 0 do not increment address, when 1 increment address in multiple writing. bit 2 -7 : address ad(5:0). this is the address field of the indexed register. bit 8-15 : data di(7:0) (wri te mode). this is th e data that will be writ ten inside the device (msb first). bit 16 -... : data di(...-8). further data in multiple byte writing. figure 8. multiple bytes spi write protocol (2 bytes example) 4.2.4 spi read in 3-wires mode 3-wires mode is entered by setting to 1 bit sim (spi serial interface mode selection) in ctrl_reg2. figure 9. spi read protocol in 3-wires mode the spi read command is performed with 16 clocks pulses: bit 0 : read bit. the value is 1. bit 1 : ms bit. when 0 do not increment address, when 1 increment address in multiple reading. bit 2-7 : address ad(5:0). this is the address field of the indexed register. bit 8-15 : data do(7:0) (read mode). this is the da ta that will be read from the device (msb first). multiple read comman d is also available in 3-wires mode. cs spc sdi rw ad5 ad4 ad3 ad2 ad1 ad0 di7 di6 di5 di4 di3 di2 di1 di0 di15 di14 di13 di12 di11 di10 di9 di8 ms cs spc sdi rw do7 do6 do5 do4 do3 do2 do1 do0 ad5 ad4 ad3 ad2 ad1 ad0 ms
registers description AN2335 16/40 5 registers description 5.1 registers address map the table given below provides a listing of the registers embedded in the device. table 4. registers address map name type register address default comment hex binary reserved (do not modify) 00-0e reserved who_am_i r 0f 00 1111 00111011 dummy register reserved (do not modify) 10-1f reserved ctrl_reg1 rw 20 10 0000 00000111 ctrl_reg2 rw 21 10 0001 00000000 ctrl_reg3 rw 22 10 0010 00000000 hp_filter_reset r 23 10 0011 dummy dummy register reserved (do not modify) 24-26 reserved status_reg r 27 10 0111 00000000 -- r 28 10 1000 not used out_x r 29 10 1001 output -- r 2a 10 1010 not used out_y r 2b 10 1011 output -- r 2c 10 1100 not used out_z r 2d 10 1101 output reserved (do not modify) 2e-2f reserved ff_wu_cfg_1 rw 30 11 0000 00000000 ff_wu_src_1(ack1) r 31 11 0001 00000000 ff_wu_ths_1 rw 32 11 0010 00000000 ff_wu_duration_1 rw 33 11 0011 00000000 ff_wu_cfg_2 rw 34 11 0100 00000000 ff_wu_src_2 (ack2) r 35 11 0101 00000000 ff_wu_ths_2 rw 36 11 0110 00000000 ff_wu_duration_2 rw 37 11 0111 00000000 reserved (do not modify) 38-3f reserved
AN2335 registers description 17/40 5.1.1 reserved registers registers marked as reserved must not be changed. random changes of the content of those registers might cause permanent damages to the device. 5.1.2 registers loaded at boot the lis302dl is factory trimmed. the content of the registers that are loaded at boot must not be changed. their content is automatically restored when the device is powered-up.
about control registers AN2335 18/40 6 about control registers 6.1 ctrl_reg1 (20h) control register #1. dr bit allows to select the data rate at which acceleration samples are produced. the default value is 0 which corresponds to a data-r ate of 100hz. by changing the content of dr to 1 the selected data-rate will be set equal to 400hz. pd bit allows to turn the device out of power-down mode. the device is in power-down mode when pd= ?0? (default value after boot). the device is in normal mode when pd is set to 1. stp, stm bits are used to activate the self test function. when one of the bit is set to 1, an output change will occur to the de vice outputs (refer to datash eet for specification) thus allowing to check the functionality of the whole measurement chain. stp and stm move the output in opposite directions. zen bit enables the generation of dataready signal for z-axis measurement channel when set to 1. the default value is 1. yen bit enables the generation of dataready signal for y-axis measurement channel when set to 1. the default value is 1. xen bit enables the generation of dataready signal for x-axis measurement channel when set to 1. the default value is 1. dr pd fs st p st m zen yen xen dr data rate selection. default value: 0 (0: 100 hz output data rate; 1: 400 hz output data rate) pd power down control. default value: 0 (0: power down mode; 1: active mode) fs full scale selection. default value: 0 (0: +/- 2g; 1: +/- 8g) stp, stm self test enable. default value: 00 (00: normal mode; 10: self test p; 01 self test m; 11: forbidden) zen z axis enable. default value: 1 (0: z axis disabled; 1: z axis enabled) ye n y axis enable. default value: 1 (0: y axis disabled; 1: y axis enabled) xen x axis enable. default value: 1 (0: x axis disabled; 1: x axis enabled) dr (datarate) pd (powerdown) status 0 0 power down (default) 0 1 active (100hz output) 1 0 power down 1 1 active (400hz output)
AN2335 about control registers 19/40 6.2 ctrl_reg2 (21h) control register #2. sim bit selects the spi serial interface mode. when sim is ?0? (default value) the 4-wire interface mode is selected. the data coming from the device are sent to sdo pad. in 3-wire interface mode output data are sent to sda/sdi pad. boot bit is used to refresh the content of internal registers stored in the flash memory block. at the device power up the content of the flash memory block is transferred to the internal registers related to trimming functions to permit a good behavior of the device itself. if for any reason the content of trimming registers was changed it is sufficient to use this bit to restore correct values. when boot bit is set to ?1? the content of internal flash is copied inside corresponding internal registers and it is used to calibrate the device. these values are factory trimmed, they are different for every accelerometer and normally they have not to be changed. at the end of the boot process the boot bit is set again to ?0?. fds bit enables (fds=1) or bypass (fds=0) the high pass filter in the signal chain of the sensor. hp ff_wu[2:1]. these bits enable (hp ff_wu=1) or bypass (hp ff_wu=0) the high pass filter in interrupt generation blocks. hp coeff[2:1] . these bits are used to configure high-pass filter cut-off frequency ft accordingly to the table given below: sim boot -- fds hp ff_wu2 hp ff_wu1 hp coeff2 hp coeff1 sim spi serial interface mode selection. default value: 0 (0: 4-wire interface; 1: 3-wire interface) boot reboot memory content. default value: 0 (0: normal mode; 1: reboot memory content) fds filtered data selection. default value: 0 (0: internal filter bypassed; 1: data from internal filter sent to output register) hp ff_wu2 high pass filter enabled for freefall/wakeup # 2. default value: 0 (0: filter bypassed; 1: filter enabled) hp ff_wu1 high pass filter enabled for free-fall/wake-up #1. default value: 0 (0: filter bypassed; 1: filter enabled) hp coeff2 hp coeff1 high pass filter cut-off frequency configuration. default value: 00 hpcoeff2,1 ft (hz) (dr=100 hz) ft (hz) (dr=400 hz) 00 2 8 01 1 4 10 0.5 2 11 0.25 1
about control registers AN2335 20/40 figure 10 shows the block diagram of the digital processing chain and the related control signals. figure 10. digital processing chain block diagram 6.3 ctrl_reg3 (22h) control register #3. ihl bit selects the polarity of the interrupt signal. when ihl is ?0? (default value) any interrupt event will signalled with a logical 1. pp_od bit defines whether the interrupt pad has to work in push-pull or in open drain mode. the latter is specifically intended for wired-or connection of multiple interrupt signals on the same interrupt line. the default value is ?0? which corresponds to push-pull mode. i2cfg [2:0] and i1cfg [2:0] bit select which signal has to be sent out from the int2 and int1 interrupt pads as described in the following table: hp filter interrupt generator (ff_wu 1) ctrl_reg2(hp ff_wu1) 0 ctrl_reg3(fds) 0 regs array digital processing chain hp_filter_reset 1 1 interrupt generator (ff_wu 2) ctrl_reg2(hp ff_wu2) 0 1 offset output regs src reg 1 src reg 2 adjustment block ihl pp_od i2cfg2 i2cfg1 i2cfg0 i1cfg2 i1cfg1 i1cfg0 ihl interrupt active high, low. default value 0. (0: active high; 1: active low) pp_od push-pull/open drain selection on interrupt pad. default value 0. (0: push-pull; 1: open drain) i2cfg2, i2cfg0 interrupt 2 configuration bits. default value 000. (see table below) i1cfg2, i1cfg0 interrupt 1 configuration bits. default value 000. (see table below)
AN2335 about control registers 21/40 two completely independent interrupt blocks are available in lis302dl: ff_wu1 and ff_wu2. they can be configured using registers described in section 8. hp filtered data can be selected for further processing by the interrupt generator block setting the desired values of hp ff_wu1 and hp ff_wu2 bits in ctrl_reg2. default value is '0' and corresponds to the use of non filtered data. the output of interrupt generator block is used to load ff_wu_src_1 and ff_wu_src_2 registers. i2cfg2 i2cfg1 i2cfg0 int2 pin i1cfg2 i1cfg1 i1cfg0 int1 pin 0 0 0 gnd 001 ff_wu 1 010 ff_wu 2 0 1 1 ff_wu1 or ff_wu2 1 0 0 dataready 111 --
data and status registers AN2335 22/40 7 data and status registers 7.1 who_am_i (0fh) device identification register. this register contains a device identifier which for lis302dl is set to 3bh. 7.2 status_reg (27h) data output status register. zyxor is set to one whenever a new acceleration data is produced before completing the retrieval of the previous set. when this occurs, the content of at least one acceleration data register (i.e. outx, outy, outz) has been overwritten. zyxor is cleared when the acceleration data (outx, outy, outz) of all the active channels are read. 00111011 zyxor zor yor xor zyxda zda yda xda zyxor x, y and z axes data overrun. default value: 0 (0: no overrun has occurred; 1: new data has overwritten the previous one before it was read) zor z axis data overrun. default value: 0 (0: no overrun has occurred; 1: a new data for the z-axis ha s overwritten the previous one) yor y axis data overrun. default value: 0 (0: no overrun has occurred; 1: a new data for the y-axis has overwritten the previous one) xor x axis data overrun. default value: 0 (0: no overrun has occurred; 1: a new data for the x-axis has overwritten the previous one) zyxda x, y and z axis new data available. default value: 0 (0: a new set of data is not yet availabl e; 1: a new set of data is available) zda z axis new data available. default value: 0 (0: a new data for the z-axis is not yet available; 1: a new data for the z-axis is available) yda y axis new data available. default value: 0 (0: a new data for the y-axis is not yet available; 1: a new data for the y-axis is available) xda x axis new data available. default value: 0 (0: a new data for the x-axis is not yet available; 1: a new data for the x-axis is available)
AN2335 data and status registers 23/40 zor is set to 1 whenever a new acceleration sample related to the z-axis is generated before the retrieval of the previous sample. when this occurs the previous sample is overwritten. zor is cleared anytime outz register is read. yor is set to 1 whenever a new acceleration sample related to the y-axis is generated before the retrieval of the previous sample. when this occurs the previous sample is overwritten. yor is cleared anytime outy_h register is read. xor is set to 1 whenever a new acceleration sample related to the x-axis is generated before the retrieval of the previous sample. when this occurs the previous sample is overwritten. xor is cleared anytime outx_h register is read. the zyxda bit signals that a new sample for all the enabled channels is available. zyxda is cleared when the acceleration data (outx, outy, outz) of all the enabled channels are read. zda is set to 1 whenever a new acceleration samp le related to the z-ax is is available. zda is cleared anytime outz register is read. in order to trigger, the zda bit requires the z axis to be enabled (bit zen=1 inside ctrl_reg1). yda is set to 1 whenever a new acceleration sample related to the y-axis is available. yda is cleared anytime outy register is read. in order to trigger, the yda bit requires the y axis to be enabled (bit yen=1 inside ctrl_reg1). xda is set to 1 whenever a new acceleration sample related to the x-axis is available. xda is cleared anytime outx register is read. in order to trigger, the xda bit requires the x axis to be enabled (bit xe n=1 inside ctrl_reg1). 7.3 outx (29h) x-axis output register. 7.4 outy (2bh) y-axis output register. . 7.5 outz (2dh) z-axis output register. . xd7 xd6 xd5 xd4 xd3 xd2 xd1 xd0 yd7 yd6 yd5 yd4 yd3 yd2 yd1 yd0 zd7 zd6 zd5 zd4 zd3 zd2 zd1 zd0
free-fall and wake-up registers AN2335 24/40 8 free-fall and wake-up registers the following sections describes the registers that are involved in the generation of the interrupt signal associated to the inertial wake-up and free-fall events. 8.1 hp_filter_reset (23h) dummy register. a reading at this address forces the high-pass filter to recover instantaneously the dc level of the acceleration signal provided to its inputs. after the above reading the output of the high -pass filter will be zero. 8.2 ff_wu_cfg_1 (30h) free-fall and wake-up configuration register for interrupt source 1. . xxxxxxxx aoi lir zhie zlie yhie ylie xhie xlie aoi and/or combination of interrupt events. default value: 0 (0: or combination of interrupt events; 1: and combination of interrupt events) lir latch interrupt request into ff_wu_src reg with the ff_wu_src reg cleared by reading ff_wu_src_1 reg. default value: 0 (0: interrupt request not latched; 1: interrupt request latched) zhie enable interrupt generation on z high event. default value: 0 (0: disable interrupt request; 1: enable interrupt request on measured accel. value higher than preset threshold) zlie enable interrupt generation on z low event. default value: 0 (0: disable interrupt request; 1: enable interrupt request on measured accel. value lower than preset threshold) yhie enable interrupt generation on y high event. default value: 0 (0: disable interrupt request; 1: enable interrupt request on measured accel. value higher than preset threshold) ylie enable interrupt generation on y low event. default value: 0 (0: disable interrupt request; 1: enable interrupt request on measured accel. value lower than preset threshold) xhie enable interrupt generation on x high event. default value: 0 (0: disable interrupt request; 1: enable interrupt request on measured accel. value higher than preset threshold) xlie enable interrupt generation on x low event. default value: 0 (0: disable interrupt request; 1: enable interrupt request on measured accel. value lower than preset threshold)
AN2335 free-fall and wake-up registers 25/40 aoi bit allows to select between wake-up (or combination of interrupt events) and free- fall (and combination of interrupt events) detection lir defines whether the configured interrupt event has to be latched by the device once it has happened. the interrupt request is cleared by reading the related source reg (ff_wu_src_1). xhie (yhie, zhie) set an interrupt event to occur when the measured acceleration data on x (y, z) channel is higher than the threshold set in ff_wu_ths_1 register. xlie (ylie, zlie) set an interrupt event to occur when the measured acceleration data on x (y, z) channel is lower than the threshold set in ff_wu_ths_1 register. the threshold module which is used by the system to detect any free-fall or inertial wake-up event is defined by ff_wu_ths_1. the threshold value is expressed over 7 bit as an unsigned number and x, (y, z) high is true when the unsigned acceleration value of the x (y, z) channel is higher than or egual to ff_wu_ths_1. similarly, x, (y, z) low is true when the unsigned acceleration value of the x (y, z) channel is lower than ff_wu_ths_1. refer to figure 11 for more details. figure 11. ff_wu_cfg_1,2 high and low value 8.3 ff_wu_src_1 (31h) free-fall and wake-up source register for interrupt 1. read only register. . + full scale - full scale 0 g level threshold module threshold module x (y, z) high x (y, z) high x (y, z) low positive negative acceleration acceleration x ia zhzlyhylxhxl ia interrupt active. default value: 0 (0: no interrupt has been generated; 1: one or more interrupt event has been generated) zh z high. default value: 0 (0: no interrupt; 1: zh event has occurred) zl z low. default value: 0 (0: no interrupt; 1: zl event has occurred) yh y high. default value: 0 (0: no interrupt; 1: yh event has occurred) yl y low. default value: 0 (0: no interrupt; 1: yl event has occurred) xh x high. default value: 0 (0: no interrupt; 1: xh event has occurred) xl x low. default value: 0 (0: no interrupt; 1: xl event has occurred)
free-fall and wake-up registers AN2335 26/40 this register keeps track of the acceleration event which is being triggering (or has triggered, in case of lir bit in ff_wu_src_1 reg set to 1) the interrupt signal. in particular ia is equal to 1 when the combination of acceleration events specified in ff_wu_cfg_1 register is true. this bit is used for the generation of the interrupt signal associated to the free-fall/wake-up events. x, (y, z) high is true when the module of the acceleration value of the x (y, z) channel is higher than the preset threshold which is de fined as the concatenation of ff_wu_ths_1. similarly, x, (y, z) low is true when the module of the acceleration value of the x (y, z) channel is lower than ff_wu_ths_1. reading at this address clears ff_wu_src_1 register and the ff_wu1 interrupt and allows the refreshment of data in the ff_wu_src_1 register itself if the latched option was chosen. 8.4 ff_wu_ths_1 (32h) free-fall, wake-up threshold for interrupt 1. dcrm bit allows to select the wa y in which the duration counte r is reset. when dcrm is 0 the duration counter is reset immediately when ever the internal inertial event programmed by the user is not active ( figure 12 part b) while it is decrem ented when dcrm is set to 1 ( figure 12 part c). the latter configuration allows to filter out spurious spikes which might impair the recognition and validation of inertial events. dcrm ths6 ths5 ths4 ths3 ths2 ths1 ths0 dcrm duration counter reset mode selection. default value: 0 (0: counter reset; 1: counter decremented) ths6, ths0 free-fall / wake-up threshold: default value: 000 0000
AN2335 free-fall and wake-up registers 27/40 figure 12. dcrm bit function 8.5 ff_wu_duration_1 (33h) set the minimum duration of the free-fall, wake-up event that must be recognized by the lis302dl.. d7, d0 define the minimum duration of the programmed inertial event such as free-fall and wake-up that must be recognized by the device. duration step and maximum value depend on the odr chosen. for an output data rate of 400 hz the register allows to set a duration spanning from 0 to 637.5 msec with steps of 2.5 msec. conversely when the output data rate is set to 100 hz it is possible to define an event duration spanning from 0 to 2.55 sec at steps of 10 msec. the counter used to implement duration function is blocked when the lir bit in the configuration register is set to one and the interrupt event has occurred. freefall event counter value duration ths freefall interrupt freefall event counter value duration ths freefall interrupt freefall event counter value duration ths freefall interrupt duration duration duration c b d7 d6 d5 d4 d3 d2 d1 d0 d7, d0 duration value. default value: 0000 0000
free-fall and wake-up registers AN2335 28/40 8.6 ff_wu_cfg_2 (34h) free-fall and wake-up configuration register for interrupt source 2. two structures can be used to generate interrupts. they have exactly the same configuration capability and they are completely independent. the interrupt result of each structure can be sent indifferently to int1 or int2 pin using ctrl_reg3 register. aoi lir zhie zlie yhie ylie xhie xlie aoi and/or combination of interrupt events. default value: 0 (0: or combination of interrupt events; 1: and combination of interrupt events) lir latch interrupt request into ff_wu_src reg with the ff_wu_src reg cleared by reading ff_wu_src_1 reg. default value: 0 (0: interrupt request not latched; 1: interrupt request latched) zhie enable interrupt generation on z high event. default value: 0 (0: disable interrupt request; 1: enable interrupt request on measured accel. value higher than preset threshold) zlie enable interrupt generation on z low event. default value: 0 (0: disable interrupt request; 1: enable interrupt request on measured accel. value lower than preset threshold) yhie enable interrupt generation on y high event. default value: 0 (0: disable interrupt request; 1: enable interrupt request on measured accel. value higher than preset threshold) ylie enable interrupt generation on y low event. default value: 0 (0: disable interrupt request; 1: enable interrupt request on measured accel. value lower than preset threshold) xhie enable interrupt generation on x high event. default value: 0 (0: disable interrupt request; 1: enable interrupt request on measured accel. value higher than preset threshold) xlie enable interrupt generation on x low event. default value: 0 (0: disable interrupt request; 1: enable interrupt request on measured accel. value lower than preset threshold)
AN2335 free-fall and wake-up registers 29/40 8.7 ff_wu_src_2 (35h) free-fall and wake-up source register for interrupt 2. read only register. refer to ff_wu_src_1 for details. reading at this address clears ff_wu_src_2 register and the ff_wu2 interrupt and al- lows the refreshment of data in the ff_wu_src_2 register if the latched option was chosen. 8.8 ff_wu_ths_2 (36h) free-fall, wake-up threshold for interrupt source 2. dcrm bit and ths6 to ths0 behave exactly like bit in ff_wu_ths_1 but they are applied to interrupt source 2. x ia zhzlyhylxhxl ia interrupt active. default value: 0 (0: no interrupt has been generated; 1: one or more interrupt event has been generated) zh z high. default value: 0 (0: no interrupt; 1: zh event has occurred) zl z low. default value: 0 (0: no interrupt; 1: zl event has occurred) yh y high. default value: 0 (0: no interrupt; 1: yh event has occurred) yl y low. default value: 0 (0: no interrupt; 1: yl event has occurred) xh x high. default value: 0 (0: no interrupt; 1: xh event has occurred) xl x low. default value: 0 (0: no interrupt; 1: xl event has occurred) dcrm ths6 ths5 ths4 ths3 ths2 ths1 ths0 dcrm duration counter reset mode selection. default value: 0 (0: counter reset; 1: counter decremented) ths6, ths0 free-fall / wake-up threshold: default value: 000 0000
free-fall and wake-up registers AN2335 30/40 8.9 ff_wu_duration_2 (37h) set the minimum duration of the free-fall, wake-up event that must be recognized by the lis302dl. refer to ff_wu_duration_1 for details. d7 d6 d5 d4 d3 d2 d1 d0 d7, d0 duration value. default value: 0000 0000
AN2335 application information 31/40 9 application information 9.1 start-up sequence once the device is powered-up it automatically downloads the calibration coefficients from the embedded flash to the internal registers. when the boot procedure is completed, i.e. approximately after 3 milli-seconds, the device automatically enters power-down mode. to turn-on the device and gather acceleration data it is necessary to write 47h inside the ctrl_reg1. with this command the three acceleration channels (i.e. x, y and z axis) are enabled and the output data rate is set to 100 hz. 9.2 reading acceleration data 9.2.1 using the status register the device is provided with a status_reg which should be polled to check when a new set of data is available. the reading procedure should be the following: the check performed at step 3 allows to understand whether the reading rate is adequate compared to the data production rate. in case one or more acceleration samples have been overwritten by new data because of a reading rate too slow, the bit status_reg(7) will be set to 1. the overrun bit are automatically cleared when all the data present inside the device have been read and new data have not been produced in the meanwhile. 9.2.2 using the data-ready signal the device may be configured to generate one hw signal (data ready) on either pin 8 or 9 to flag that a new set of measurement data is available for reading. this signal corresponds to the zyxda bit present inside the status_reg. the polarity of the signal is defined through the ihl bit present inside the ctrl_reg3 and it is deasserted when the acceleration data of all the enabled channels have been read. to enable data ready signal on pin #8 (corresponding to int1) it is necessary to set i1cfg[2:0] bit present inside the ctrl_reg3 to 100. conversely, to enable data ready signal on pin #9 (corresponding to int2) it is necessary to set i2cfg[2:0] bit present inside the ctrl_reg3 to 100. 1 read status_reg 2 if status_reg(3)=0 then goto 1 3 if status_reg(7)=1 then some data have been overwritten 4 read outx 5 read outy 6 read outz 7 data processing 8 goto 1
application information AN2335 32/40 9.3 understanding acceleration data the measured acceleration data are sent into outx, outy and outz registers. the acceleration values are expressed as a 2?s complement number. when the full-scale is set to 2g, each lsb corresponds to 18mg. the table below provides few basic examples of the data that will be read in the data registers when the device is subject to a given acceleration. the values listed in the table are given under the hypothesis of perfect device calibration (i.e no offset, no gain error, ....) and rounded to the closest integer. table 5. output data registers content vs. acceleration acceleration values fs bit = 0 fs bit = 1 output register content 0g 00h 00h 350mg 14h 05h 1g 38h 0eh 2g 6fh 1ch -350mg ech fbh -1g c8h f2h -2g 91h e4h
AN2335 application information 33/40 9.4 interrupt generation description the lis302dl provide two fully-programmable interrupt sources which may be configured to trigger different inertial events. among them it is worth mentioning the recognition of free- fall and wake-up events. whenever an interrupt condition is verified the interrupt signal is asserted and reading either the ff_wu_src_1 or ff_wu_src_2 registers it is possible to understand which condition has occurred. the block diagram of the interrupt block is given in the pictures below. figure 13. interrupt generation block diagram figure 14. free-fall, wake-up interrupt generator ff or wu interrupt generation is selected for each interrupt generation channel through aoi bit in the corresponding ff_wu_cfg register. if aoi bit is ?0? signals coming from comparators are put in logical or. depending on values written in ff_wu_cfg_1 and ff_wu_cfg_2 registers every time the value of at least one of the enabled axes exceeds the threshold written in module in the corresponding ff_wu_ths_1 and ff_wu_ths_2 registers a ff, wu interrupt is generated. otherwise if aoi bit is ?1? signals coming from comparators are going into a ?nand? port. in this case an interrupt signal is generated whenever the acceleration signal of all the enabled axes is below the threshold written in ff_wu_ths_1 or ff_wu_ths_2 registers. ph_gen ctrl_reg1(dr,pd) 100/400hz adc 0 1 0 1 0 1 hp filter output reg ff_wu2 ff_wu1 src1 src2 serial interface (spi & i2c) cfg 1 cfg 2 ctrl_reg2(fds) ctrl_reg2(hp ff_wu1) ctrl_reg2(hp ff_wu2) ths reg |b|>a? |b|>a? |b|>a? accel_x accel_y accel_z x_en y_en z_en wu ff 0 1 ff_wu_cfg(aoi)
application information AN2335 34/40 ff_wu_cfg(lir) bit permits to decide if the interrupt request has to be latched or not. if lir bit is ?0? (default value) interrupt signal goes high when the interrupt condition is satisfied and comes back low immediately if the interrupt condition is no more verified. otherwise if lir bit is ?1? whenever a interrupt condition is applied the interrupt signal remains high even if the condition comes back to non-interrupt status until a reading to ff_wu_src register is performed. the remaining bits of ff_wu_cfg register per mits to decide on which axis the interrupt decision has to be performed and on which direction the threshold has to be passed to generate the interrupt request. 9.5 inertial wake-up 9.5.1 hp filter bypassed this paragraph provides a basic algorithm which shows the practical use of the inertial wake-up feature. in particular, with the code below, the device is configured to recognize when the absolute acceleration along either x or y axis exceeds a preset threshold (180mg used in the example). the event which triggers the interrupt is latched inside the device using ff_wu interrupt source 1 and its occurrence is signalled through the usage of the int2 pin. 1 write c7h into ctrl_reg1 // turn on the sensor and set odr=400hz 2 write 00h into ctrl_reg2 // default value: high pass filter bypassed 3 write 08h into ctrl_reg3 // ff_wu1 interrupt sent to int2 pin 4 write 0ah into ff_wu_ths_1 reg // set wake-up threshold = 180 mg 5 write 00h into ff_wu_duration_1 reg // no filtering/confirmation on the event 6 write 4ah into ff_wu_cfg_1 // configure desired wake-up event 7 poll int2 pin; if int2=0 then goto 7 // poll int2 pin waiting for the wake-up event 8 read ff_wu_src_1 reg // return the event that has triggered the interrupt // clear interrupt request 9 (wake-up event has occurred; insert your code here) // event handling 10 goto 7
AN2335 application information 35/40 9.5.2 using the hp filter the code provided below gives a basic routine which shows the practical use of the inertial wake-up feature performed onto high-pass filtered data. in particular the device is configured to recognize when the high-frequency component of the acceleration applied along either x, y or z axis exceeds a preset threshold (180mg used in the example). the event which triggers the interrupt is latched in side the device using ff_wu interrupt source 1 and its occurrence is signalled through the usage of the int1 pin. at step 6, a dummy read at hp_filter_ reset register is performed to set the current/reference acceleration/tilt state against which the device performed the threshold comparison. this read may be performed any time it is required to set the orientation/tilt of the device as a reference state without waiting for the filter to settle. 1 write c7h into ctrl_reg1 // turn on the sensor and set odr=400 hz 2 write 04h into ctrl_reg2 // high pass filter enabled on ff_wu1, fcut- off= 8hz 3 write 01h into ctrl_reg3 // ff_w u1 interrupt sent to int1 pin 4 write 0ah into ff_wu_ths_1 reg // set wake-up threshold = 180 mg 5 write 00h into ff_wu_duration_1 reg // no filtering/confirmation on the event 6 read hp_filter_reset register // dummy read to force the hp filter to // actual acceleration value // (i.e. set reference a cceleration/tilt value) 7 write 6ah into ff_wu_cfg_1 // configure desired wake-up event 8 poll int1 pin; if int1=0 then goto 7 // poll int1 pin waiting for the wake-up event 9 (wake-up event has occurred; insert your code here) // event handling 10 read ff_wu_src_1 reg // return the event that has triggered the interrupt // clear interrupt request 11 (insert your code here) // event handling 12 goto 8
application information AN2335 36/40 9.6 free-fall detection 9.6.1 roll function not used this paragraph provides the basics for the use of the free-fall detection feature. in particular the sw routine that configures the device to detect free-fall events and to signal them is the following: the code sample exploits a threshold set at 350mg for free-fall recognition and the event is notified by the hardware signal int2 pin. at step 5, the ff_wu_duration_1 register is configured so to ignore events that are sh orter than 9/odr=9/100~90msec (odr=output data rate) in order to avoid false detections. once the free-fall event has occurred, a dummy read at ff_wu_src_1 reg clears the request and the device is ready to recognize other events. 9.6.2 roll function applied roll function can be added to free-fall condition recognition using both interrupt sources. interrupt signals can be sent to two different pins (int1, int2) or can be sent to the same so that the first condition that is verified take control of the pin (logic ?or? of interrupt signals). 1 write 47h into ctrl_reg1 // turn on the sensor and set odr=100 hz 2 write 00h into ctrl_reg2 // default value: high pass filter bypassed 3 write 08h into ctrl_reg3 // ff_w u1 interrupt sent to int2 pin 4 write 14h into ff_wu_ths_1 re g // set the free-fall threshold 5 write 09h into ff_wu_duration_1 reg // set minimum event duration to 90 msec 6 write d5h into ff_wu_cfg_1 // configure free-fall recognition and latch // interrupt request 7 poll int2 pad; if int2=0 then goto 7 // poll int2 pin waiting for the free-fall event 8 (free-fall event has occurred; insert your code here) // event handling 9 read ff_wu_src_1 register // clear interrupt request 10 goto 7
AN2335 application information 37/40 9.7 output data rate se lection and reading timing the output data rate is user selectable through dr bit stored in ctrl_reg1 (20h) register. at power-on-reset dr is reset to 0 thus providing a default output data rate set to 100 hz. the selectable output data rate are given in table below: the output data rate precision is related to internal oscillator or to external clock precision and an error of +/- 10% should be taken in account. the output data rate precision is related to internal oscillator or to external clock precision and an error of +/- 10% should be taken in account. a minimum reading period 150 s shorter than the output data rate period is defined not to loose any data produced. during this time period the reading of the data must be performed and dataready signal can be used as a trigger to begin the reading sequence. at the end of the complete sequence dataready signal goes down and the following rise edge advise that new data are available. if this minimum reading frequency is not observed it is possible to loose some data and the dataready signal have no more the meaning of a trigger signal. the status register can be used to infer whether an overrun condition has happened. figure 15. reading timing table 6. output data rate dr output data rate 0 100 hz 1 400 hz table 7. timing value to avoid loosing the data time description min typ max t0 data rate 2.5 ms 10 ms t1 reading period t0-t2 t2 new data generation 150 s dataready t0 t2 t1 new data available
application information AN2335 38/40 9.8 data ready vs. interrupt signal the device is provided with two pins which can be activated to generate either the dataready or the interrupt signal. the functi onality of the pins are selected acting on interrupt configuration bit located in ctrl_reg3(2-0) for interrupt pin 1 (int1) and in ctrl_reg3(5-3) for interrupt pin 2 (int2) accordingly to the block diagram given in figure 16 . in particular the dataready signal, stored in status_reg(3), which indicates when a new set of acceleration data is ready, is made available by setting cfg bit to 100, while the interrupt source 1 signal is carried out when cfg bit are set to 001 and interrupt source 2 when cfg bit are set to 010. a logic ?or? combination of interrupt source 1 and 2 can be sent to an interrupt pin writing 011 in cfg bit. figure 16. interrupt and dataready signal generation block diagram the data-ready signal is risen to 1 when a new set of acceleration data has been generated and it is available for reading. the signal is reset after all the enabled channels are read through the serial interface. figure 17. data ready signal ctrl_reg3(2,1,0) 0 int1 signal 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 1 1 free-fall, wake-up interrupt interrupt counter clock (100/400hz) ff_wu_duration latch ff_wu_cfg1(lir) generator generator 0 1 dataready signal dataready signal generator interrupt generator (ff_wu_1, 2) ia ia (ff_wu_src_1) (ff_wu_src_2) latch ff_wu_cfg2(lir) 0 1 free-fall, wake-up counter clock (100/400hz) ff_wu_duration 1 2 ctrl_reg3(5,4,3) 0 int2 signal 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 1 1 rdy data read accel data accel. sample #(n) accel. sample #(n+1) xyz xyz
AN2335 revision history 39/40 10 revision history table 8. document revision history date revision changes 03-aug-2006 1 initial release. 20-oct-2006 2 changes in the pages 8, 18 & 21.
AN2335 40/40 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by an authorized st representative, st products are not recommended, authorized or warranted for use in milita ry, air craft, space, life saving, or life sustaining applications, nor in products or systems where failure or malfunction may result in personal injury, death, or severe property or environmental damage. st products which are not specified as "automotive grade" may only be used in automotive applications at user?s own risk. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2006 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN2335

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X