Not your typical 'small' I2C module/Mt9D111 register crib-notes.

A project log for Digital Holga

Conversion of a Holga 120S to digital format with SD card output.

AnthonyAnthony 02/23/2015 at 11:310 Comments

An important note to keep in mind from the Micron User Guide/Datasheet. In addition to having registers that run up to the range of 0xFF (255) instead of your more common 0x7F (127), the registers for various functions are divided into three pages (0, 1, and 2) as described in the manual:

"Hardware registers are organized into several pages. Page 0 contains sensor controls. Page 1 contains color pipeline controls. Page 2 contains JPEG, output FIFO and more color pipeline controls. The desired page is selected by writing the desired value to R0xF0. After that all READs and WRITEs to registers 0..255 except R0xF0 and R0xF1, is directed to the selected page. R0xF0 and R0xF1 are special registers and are present on all pages."

Meaning, of course the 0xF0 (page register) and 0xF1 (byte-wise address) must be set to the proper page to gain access to the specific hardware register.

Thus, consider the following standard (at boot) hardware reset instructions:

"A soft reset to the camera can be activated by the following procedure:

1. Bypass the PLL, R0x65:0=0xA000, if it is currently used

2. Perform MCU reset by setting R0xC3:1=0x0501

3. Enable soft reset by setting R0x0D:0=0x0021. Bit 0 is used for the sensor core reset

while bit 5 refers to SOC reset.

4. Disable soft reset by setting R0x0D:0=0x0000

5. Wait 24 clock cycles before using the two-wire serial interface"

Thus, considering the above, step one, register 0x65 lies on (and can only be accessed from) page zero. Similarly "R0xC3:1" translates that "Register 0xC3 lies only on page one", etc.

Finally, one last item to consider: The majority of Mt9D111 registers are 16-bit, thus with the most common 8-bit i2c libraries at least, a read/write will require two calls to the corresponding operation (i.e. two subsequent 'write' commands, 8 bits each), with the data being sent out appropriately bitshifted.