In order to explain how to read a specific register we will give you a simple example reading the ''Chip Version'' register, this is the 0x000 register of the sensor.

In order to explain how to read a specific register we will give you a simple example reading the ''Chip Version'' register, this is the 0x000 register of the sensor.

−

Whatever register you want to read you must use the following command:

+

You can read a register by using the following command:

<pre>

<pre>

Line 69:

Line 69:

</pre>

</pre>

−

Almost all the fields showed were already explained, the only one we haven't speak yet is the ''MODE'' field, this field allows to us to specify the the read mode, that is byte-read (b) or word-read (w). Since the MT9P031 have 16bit registers we must use work-read. The following is the command used to read the ''Chip Version'' register:

+

Almost all the fields showed were already explained, the only one we haven't speak yet is the ''MODE'' field, this field allows to us to specify the read mode, that is byte-read (b) or word-read (w). Since the MT9P031 have 16bit registers we must use work-read. The following is the command used to read the ''Chip Version'' register:

<pre>

<pre>

Line 95:

Line 95:

Where ''VALUE'' is the value to be written to the register.

Where ''VALUE'' is the value to be written to the register.

−

As an example we will modify the register 160 (0x0A00) or ''Test_Pattern_Control'' register.

+

As an example we will modify the register 32 (0x020) or ''Read Mode 2 (RW)'' register.

+

+

1. Run the following pipeline, it will run a video capture from the camera to the composite output. You should see a normal vertical image in your display device.

We can see now the presence of the camera sensor at the address 0x48, we need this address in order to tell the i2c-tools which device we want to access.

How can we read a specific register?

In order to explain how to read a specific register we will give you a simple example reading the Chip Version register, this is the 0x000 register of the sensor.

You can read a register by using the following command:

i2cget -f -y I2CBUS CHIP-ADDRESS DATA-ADDRESS MODE

Almost all the fields showed were already explained, the only one we haven't speak yet is the MODE field, this field allows to us to specify the read mode, that is byte-read (b) or word-read (w). Since the MT9P031 have 16bit registers we must use work-read. The following is the command used to read the Chip Version register:

i2cget -f -y 1 0x48 0x000 w

After run this command you must get the following outpu:

0x0118

If you see the MT9P031's datasheet you will see that the correct Chip Version register's value is 0x1801. The reason we got a different value is because MT9P031 uses big endian and i2cget uses little endian, so you only need to swap the value obtained in order to get the correct one.

NOTE: You must remember to swap the value gotten with i2cget in order to get the correct register's value.

How can we write a specific register?

If you want to write a specific register you must use the following command:

i2cset -f -y I2CBUS CHIP-ADDRESS DATA-ADDRESS VALUE MODE

Where VALUE is the value to be written to the register.

As an example we will modify the register 32 (0x020) or Read Mode 2 (RW) register.

1. Run the following pipeline, it will run a video capture from the camera to the composite output. You should see a normal vertical image in your display device.