Uncorrect setup of averaging
When using the averaging feature (setup by register 0x15), new data is available at a frequency = f_sample/N. The sum of the previous N samples is divided by N before being transferred to the FIFO.
According to the datasheet p.25, if pulse counts registers are kept to 8 or else (8 pulses I presume ???), the 16-bit width is never exceeded.
If averaging factors of Slot A & B are the same, both time slots can be saved to the FIFO. In order to access the data in the FIFO, two methods can be used, interrupt or non-interrupt:
- Interrupt method will rely on GPIO pins, so the microcontroller should be setup to deal with hardware interrupts.
- Non-interrupt, AKA polling method.
The polling method is described in the datasheet :
To read data from the FIFO in a polling method, use the following procedure:
- In program mode, set the configuration of the time slots as desired for operation.
- Write to Register 0x11 with the desired data format for each time slot.
- Enter normal operation mode by setting Register 0x10 to 2.
Next, begin the polling operations.
- Wait for the polling interval to expire.
- Read the FIFO_SAMPLES bits (Register 0x00, Bits[15:8]).
- If FIFO_SAMPLES ≥ the packet size, read a packet using the following steps: a. Read a complete packet using one or more multiword accesses via Register 0x60. Reading the FIFO automatically frees the space for new samples. b. Repeat Step 1.
A function should be added to read the FIFO_SAMPLE bits.
Edited by Vincent Raimbault