Memory pages, counters, scratchpad
Address space of the device consists of 16 memory pages, each 32 bytes in size:
Page | Addresses | Contents | Counter |
0 | 0x000 .. 0x01f | Settings and status data | - |
1 | 0x020 .. 0x03f | Reserved | - |
2 | 0x040 .. 0x05f | Reserved | - |
3 | 0x060 .. 0x07f | Reserved | - |
4 | 0x080 .. 0x09f | Reserved | - |
5 | 0x0a0 .. 0x0bf | Scratchpad | - |
6 | 0x0c0 .. 0x0df | User data, status data | - |
7 | 0x0e0 .. 0x0ff | Scratchpad (copy) | - |
8 | 0x100 .. 0x11f | Settings and status data (copy) | - |
9 | 0x120 .. 0x13f | Reserved | - |
10 | 0x140 .. 0x15f | Reserved | - |
11 | 0x160 .. 0x17f | Reserved | - |
12 | 0x180 .. 0x19f | Reserved | - |
13 | 0x1a0 .. 0x1bf | Scratchpad (copy) | - |
14 | 0x1c0 .. 0x1df | User data, status data (copy) | A |
15 | 0x1e0 .. 0x1ff | Scratchpad (copy) | B |
Each memory page has a 32-bit counter associated with it. Counters A and B are tied to pages 14 and 15, respectively, the counters of the remaining pages are not used and always have a value of 0. The value of any of the 16 counters can be obtained with a special request (0xA5 READ MEM COUNTER), which guarantees atomic reading of the counter. The value of counters A and B can also be obtained by reading bytes 0..7 of pages 0 or 8, in which the values of counters A and B are mapped, but in this case the reading is not performed atomically (increment of counter can occur between sequential reading of counter bytes). Writing counters A and B is possible only by writing to bytes 0..7 of memory page 0, writing will be performed atomically.
Reading data from memory addresses is performed directly (0xA5 READ MEM COUNTER), while writing is performed with the help of a special 32 bytes Scratchpad memory area: first, data is written to Scratchpad (0x0F WRITE SCRATCH), and then atomically copied from Scratchpad to specified memory addresses (0x5A COPY SCRATCH). The contents of Scratchpad can be read either by a special request (0xAA READ SCRATCH) or by reading memory pages 5,7,13 and 15, in which Scratchpad is mapped. Writing to Scratchpad or any of pages 5,7,13 or 15 changes only Scratchpad and its copies in those pages. Writing to other pages will overwrite Scratchpad and its copies with the written data.
Settings and status data
The state and settings of the device are stored in a memory area, one part of which is mapped in memory pages 0 and 8 (both are mapped to the same part of the state and settings) and other part in bytes 24..31 of pages 6 and 14 (both are mapped to the same part of the state).
All state and settings bytes are available for reading. Only bytes 0..7 of page 0 (counter values) and bytes 8..13 of page 8 (settings) are available for writing.
All bytes in pages 1..4, 9..12, as well as bytes 14..16, 18..31 in pages 0 and 8 and bytes 25..31 in pages 6 and 14 are reserved.
Addresses 0x000..0x003 and 0x100..0x103
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Offset in page: 0 | Counter A:[7..0] | |||||||
Offset in page: 1 | Counter A:[15..8] | |||||||
Offset in page: 2 | Counter A:[23..16] | |||||||
Offset in page: 3 | Counter A:[31..24] | |||||||
Access in page 0 | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Access in page 8 | R | R | R | R | R | R | R | R |
Default | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Counter A in normal operating mode (not in Measure mode), 4 bytes, LSB first.
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Offset in page: 0 | Counter A:[7..0] | |||||||
Offset in page: 1 | Counter A:[15..8] | |||||||
Offset in page: 2 | Measure Min:[7..0] | |||||||
Offset in page: 3 | Measure Max:[7..0] | |||||||
Access in page 0 | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Access in page 8 | R | R | R | R | R | R | R | R |
Default | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
In the Measure mode, two most significant bytes of counter A are used to accumulate statistics of the minimum and maximum value of the digitized analog signal for samples that have passed the filter (if the analog mode is activated by setting: threshold rising > threshold falling, otherwise min and max values are undefined).
Addresses 0x004..0x007 and 0x104..0x107
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Offset in page: 4 | Counter B:[7..0] | |||||||
Offset in page: 5 | Counter B:[15..8] | |||||||
Offset in page: 6 | Counter B:[23..16] | |||||||
Offset in page: 7 | Counter B:[31..24] | |||||||
Access in page 0 | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Access in page 8 | R | R | R | R | R | R | R | R |
Default | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Counter B in normal operating mode (not in Measure mode), 4 bytes, LSB first.
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Offset in page: 4 | Counter B:[7..0] | |||||||
Offset in page: 5 | Counter B:[15..8] | |||||||
Offset in page: 6 | Measure Samples:[7..0] | |||||||
Offset in page: 7 | Measure Samples:[15..8] | |||||||
Access in page 0 | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Access in page 8 | R | R | R | R | R | R | R | R |
Default | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
In the Measure mode, two most significant bytes of counter B are used to accumulate statistics of the number of samples that have passed the filter. Samples, 2 bytes, LSB first.
Addresses 0x008..0x00b and 0x108..0x10b
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Offset in page: 8 | Threshold falling A:[7..0] | |||||||
Offset in page: 9 | Threshold rising A:[7..0] | |||||||
Offset in page: 10 | Threshold falling B:[7..0] | |||||||
Offset in page: 11 | Threshold rising B:[7..0] | |||||||
Access in page 0 | R | R | R | R | R | R | R | R |
Access in page 8 | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Default | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Thresholds - values used to convert digitized analog value to logical state:
Digitized analog value on input is V | Converted logical state of input |
Threshold falling >= Threshold rising | conversion is off, state is read directly from input |
V < Threshold falling | low |
V > Threshold rising | high |
Threshold falling <= V <= Threshold rising | previous state |
Addresses 0x00c and 0x10c
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Offset in page: 12 | PINCA | PINCB | PUDA | PUDB | SPWR1 | SPWR0 | PUT1 | PUT0 |
Access in page 0 | R | R | R | R | R | R | R | R |
Access in page 8 | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Default | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
PINCA/PINCB - enable counter A/B increment mode on both edges (see table of states in EDGEA/EDGEB bit description).
PUDA/PUDB - disable pull-up resistor between power supply and A/B input:
PUD | Mode |
0 | Pull-up enabled |
1 | Pull-up disabled |
SPWR[1..0] - sensors power supply mode:
SPWR1 | SPWR0 | Mode |
0 | 0 | PWR pin is always off |
0 | 1 | Pulse power supply on PWR pin |
1 | 0 | PWR pin is used as input B, pulse power supply on B pin |
1 | 1 | Power supply on PWR pin is always on |
PUT[1..0] - delay after turning on pull-ups and powering the sensors and
before sampling inputs A and B:
PUT1 | PUT0 | Mode |
0 | 0 | 25 us |
0 | 1 | 50 us |
1 | 0 | 125 us |
1 | 1 | 425 us |
Addresses 0x00d and 0x10d
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Offset in page: 13 | EDGEA | EDGEB | MSRP | MSRL | MSRA | MSRB | SMP1 | SMP0 |
Access in page 0 | R | R | R | R | R | R | R | R |
Access in page 8 | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W |
Default | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 1 |
EDGEA/EDGEB - edge used for counter A/B increment:
PINC | EDGE | Mode |
0 | 0 | Increment on falling edges |
0 | 1 | Increment on rising edges |
1 | any | Increment on both edges |
MSRP - device power mode filter in Measure mode:
MSRP | Mode |
0 | Accumulate statistics only when operating on battery power |
1 | Accumulate statistics only when operating from external power supply |
MSRL - input logical level filter in Measure mode:
MSRL | Mode |
0 | Accumulate statistics only when measured input is in low logical state |
1 | Accumulate statistics only when measured input is in high logical state |
MSRA,MSRB - enable Measure mode for input A/B:
MSRA | MSRB | Mode |
0 | 0 | Normal operating mode |
0 | 1 | Measure mode for input B |
1 | 0 | Measure mode for input A |
1 | 1 | Reserved |
SMP[1..0] - interval between samples:
SMP1 | SMP0 | Mode |
0 | 0 | 19 ms |
0 | 1 | 38 ms |
1 | 0 | 75 ms |
1 | 1 | 150 ms |
Addresses 0x011 and 0x111
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Offset in page: 17 | Level A | Level B | Reserved | |||||
Access in page 0 | R | R | R | R | R | R | R | R |
Access in page 8 | R | R | R | R | R | R | R | R |
Default | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Level A/B - current logical state of inputs A and B, 0 - low, 1 - high.
Addresses 0x0d8 and 0x1d8
Bit | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Offset in page: 24 | Battery:[7..0] | |||||||
Access in page 6 | R | R | R | R | R | R | R | R |
Access in page 14 | R | R | R | R | R | R | R | R |
Default | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Battery - current value representing voltage of the CR2032 battery. The battery voltage in Volts can be calculated using the formula Vbat = (VCC - 0.68V) * Battery / 256. In Measure mode, the Battery value is undefined.
User data
Bytes 0..23 of pages 6 and 14 (both pages are a mapping of each other) are available for storing user data.
The entire Scratchpad page can also be used to store user data, but before writing any other memory page, the Scratchpad contents must be read and remembered, and after writing, the remembered contents must be restored on device again. Thus, 56 bytes can be available for storing user data.