Subsection 12.4.2 CTRL_REG1_A: Data Rate, Power Mode, and Axes
Open the LSM303AGR datasheet to §8.6 (p. 47). Tables 33 and 34 describe
CTRL_REG1_A, at register address 0x20: which bit is which, and what each field selects (Figure 12.4.1). The top four bits, ODR[3:0] (ODR here is the output data rate, a different ODR than the GPIO output data register from the earlier chapters), set how often the sensor takes a reading; the LPen bit (low-power enable) selects between normal mode and low-power mode; and the bottom three bits, Zen, Yen and Xen, enable the three axes independently, one bit per axis.
/ctrl_reg1_fields.png)
CTRL_REG1_A and what each field selects. ODR[3:0] is the output data rate, LPen enables low-power mode, and Zen, Yen, and Xen enable the three axes.The data rates themselves are in Table 35, on the same page (Figure 12.4.2): each nonzero ODR[3:0] pattern selects one rate, from 1 Hz up to the kilohertz range, and 0000 is power-down. Here is what we want from the sensor this week: readings at 400 Hz, in normal mode, with all three axes enabled. Find the four ODR bits that select 400 Hz, decide what LPen must be, and decide what the three axis-enable bits must be. The resulting eight-bit value is your
CTRL_REG1_A setting, and on Thursday we’ll compare answers before we put it into the sensor.
/ctrl_reg1_rates.png)
