This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2C read/write Errors

Hi,

        I am currently using the MT9J003 sensor with IPNC_release_v3.00 on DM8127 H/W.

I2C protocol is used for peripheral read/write (sensor read/write).

Once My setup is up, I get the root login prompt on the minicom. I executed below commands and got Errors.

root@DM8127_IPNC:~#

root@DM8127_IPNC:/# cd /opt/ipnc/bin/
root@DM8127_IPNC:/opt/ipnc/bin# pwd
/opt/ipnc/bin
root@DM8127_IPNC:/opt/ipnc/bin#

 root@DM8127_IPNC:/opt/ipnc/bin# ./i2c_rdwr.out
 I2C Test Utility,
 Usage: ./i2c_rdwr.out -r|-w <devAddrInHex> <regAddrInHex> <regValueInHex or numRegsToReadInDec>
 root@DM8127_IPNC:/opt/ipnc/bin#

root@DM8127_IPNC:/opt/ipnc/bin# ./i2c_rdwr.out -r 0x36 0x02 1
 ERROR  (osa_i2c.c|OSA_i2cTestMain|263): OSA_i2cOpen( instId = 3 )
root@DM8127_IPNC:/opt/ipnc/bin# ./i2c_rdwr.out -r 0x36 0x49 1
 ERROR  (osa_i2c.c|OSA_i2cTestMain|263): OSA_i2cOpen( instId = 3 )
root@DM8127_IPNC:/opt/ipnc/bin#

Querries:

#1. My setup is ready and Streaming the data smoothly over RTSP, it is expected to use I2c read/write and it's doing so.

       But When I try to use ./i2c_rdwr.out command why it throws Error? Both read & write (-r/-w) doesn't work here, and throws same error.

I hope, cmd used is correct. {ex: root@DM8127_IPNC:/opt/ipnc/bin# ./i2c_rdwr.out -r 0x36 0x49 1}. If any mistake please do correct it.

#2. Referring to osa_i2c.h what is I2C_DEFAULT_INST_ID? what does it signifies? how u decide the ID value ? any reference please?

Regards

Ravikiran



 

  • Ravi,

    1. First check whether it expects 7-bit or 8-bit slave id. What is the "7-bit" slave id of your sensor? Please try left shift or right shift the slave id and pass it and see?

    2. I2C instance ID is I2C controller's number. There are three or four I2C controllers in the device. The selection of instance should be based on which controller the camera sensor is physically connected to. You can easily figure it out using the schematics of your board. In your case I guess, it should remain same as another sensor is already working using the same board/connector.

  • Hi Renjith,

    Thank you for ur precious reply.

                 Yes now I am able to access I2c, in the sense Its opening the device successfully after changing the I2c_dev_Id from 3 to 1 in my code ..!!

    But I couldn't read or write using that I2c. I suspect this read/write failed bcz, My sensor is connected to I2c H/W with devID=3 &  I am trying to read from devID=1 which is wrong.  So that is expected...!! Now my understanding is that, the device with devID=3 was already opened by sensor & I was trying to re-open it, which is not correct.  M I right?  Please correct me if I am  wrong.  

    Now m trying to understand the I2C init/create part, ur help will be really crucial at this point.

    Please confirm my below understanding about I2C implementation on DM8127  w.r.t IPNC_REALEASE_V3.00

    #1. Support for I2C device in the Kernel is enabled using .config file. i.e. arch/arm/configs/xxxxxx  {ti_tools/ipnc_psp_04_04_00_01/kernel}.

    #2. The code available in psp & iss is just the framework to utilize the support provided by kernel.

              If above 2 things are true, then what is the role of I2C code available in u-boot?.

    Thanks in advance.

    Regards

    Ravikiran.

     

  • Ravi,

    Hardware I2C controllers are shared between M3 and A8. So it doesn't really matter where it is used. Ideally if you are using a controller in M3, you shouldn't be sharing the same controller to connect a device which has a driver only in A8 as both the I2C drivers will be access the controller simultaneously. 

    As mentioned earlier, the instance ID is purely based on the I2C controller, where your device is connected to. Also opening a device multiple times may not be a real issue as the access protection will be taken care by the driver.

  • Hi Renjith,

                   Currently I am trying to build a framework that can give an interface b/w. my sensor API's and SPI driver.

    Its expected to build a structured code for SPI in our ipnc_rdk_v3.00 iss & hdvpss package. (As it is organized for other protocol like I2C)

    For that I m not able to understand how to start with it. 

    Please can you guide me in getting started with this activity.

    Thanks in advance.

  • Ravi,

    You can start defining APIs for read/write registers, which will take arguments for your camera registers and a device id or some object for that. You can then use that API for you sensor initializations in a sequential order. But first you've to try reading a register from the camera module to see whether SPI read is working fine or not.