cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

nich_4171101
New Contributor II

Hi Kandla,

I've already changed the sensor ID based on the MT9v034 in sensor.c, by using UART log still showing Reading sensor ID failed!

Please advise

pastedImage_3.png

According to datasheet MT9V034 sensor id is  0x1324

The 0x00, 0x00 is actually what address ?

pastedImage_2.png

Thanks & Regards,

Nigel

0 Likes
1 Solution
KandlaguntaR_36
Moderator
Moderator

Reading sensor ID issue is solved by setting proper I2C Configuration as per the sensor requirement.

View solution in original post

0 Likes
24 Replies
KandlaguntaR_36
Moderator
Moderator

Nigel,

The 0x00, 0x00 is the memory location that we are tryting to read - considering that Sensor ID is located in 0x0000 address.

Please refer the source code of SensorRead2B.

In the default AN75779 firmware, the sensor ID is located at 0x00, 0x00 location.

Can you please print the buf[2] here and check whether it is matching the Sensor ID?

0 Likes
nich_4171101
New Contributor II

HI Sridhar,

May i know where should i print  buf[2], is it in the sensor.c file------>from the funtion of SensorI2cBusTest  ??

Rgds

Nigel

0 Likes
KandlaguntaR_36
Moderator
Moderator

You can print in sensor.c file in I2CBusTest function itself.

Regards,

Sridhar

0 Likes
nich_4171101
New Contributor II

Hi Sridhar,

Can i used the way below to print out the buf[0] and buf[1]  ??

====================================================================

uint8_t SensorI2cBusTest(void) {

/* The sensor ID register can be read here to verify sensor connectivity. */

uint8_t buf[2];

/* Reading sensor ID */

     if (SensorRead2B(SENSOR_ADDR_RD, 0x00, 0x00, buf) == CY_U3P_SUCCESS) {

          CyU3PDebugPrint("%d", buf[0]);

          CyU3PDebugPrint("%d", buf[1]);

     return 1;

}

=====================================================================

Rgds

Nigel

0 Likes
KandlaguntaR_36
Moderator
Moderator

Add priority value to this API CyU3PDebugPrint(4, "%d", buf[0]); CyU3PDebugPrint(4, "%d", buf[1]);

0 Likes
nich_4171101
New Contributor II

Hi Sridhar,

This is how i wrote the program to print =======>uint8_t buf[2];

                                                                                SensorRead2B (SENSOR_ADDR_RD, 0x00, 0x00, buf);

                                                                                CyU3PDebugPrint(4, "%d", buf[0]);

                                                                                CyU3PDebugPrint(4, "%d", buf[1]);

On the uart log it shows this :

Entering USB Suspend Mod 00UsbEventCB: Detected SS USB Connection

USBSetupCB:In SET_FTR 0::1

USBSetupCB:In SET_FTR 0::1

USBSetupCB:In SET_FTR 0::1

UsbEventCB: SUSPEND encountered...

Entering USB Suspend

0 Likes
KandlaguntaR_36
Moderator
Moderator

Can you please do this?

uint8_t

SensorI2cBusTest (

        void)

{

    /* The sensor ID register can be read here to verify sensor connectivity. */

    uint8_t buf[2];

     CyU3PDebugPrint(4, "I am in bus test \r\n");

    /* Reading sensor ID */

    if (SensorRead2B (SENSOR_ADDR_RD, 0x00, 0x00, buf) == CY_U3P_SUCCESS)

    {

        CyU3PDebugPrint(4, "%d\n\r", buf[0]);

        CyU3PDebugPrint(4, "%d\n\r", buf[1]);

        if ((buf[0] == 0x24) && (buf[1] == 0x81))

        {

            return CY_U3P_SUCCESS;

        }

    }

     else

          {

               CyU3PDebugPrint(4, "Reading 0x0000 location of sesnor is failing \r\n");

          }

    return 1;

}

0 Likes
KandlaguntaR_36
Moderator
Moderator

Please use the Debugprints in your firmware except in callback functions and find where it is going wrong.

In your last response, there is no debug print related to Sensor ID if the SensorRead2B  is success you should see the buf 0 and buf 1 values.

You may use JTAG debugger as well. If you are using SuperSpeed Explorers kit, you can also integradted OpenOCD debugger as well.

Please refer UserGuide provided in documentation folder of the SDK: C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\doc\firmware

0 Likes
nich_4171101
New Contributor II

Hi Sridhar,

I have tested the code that you shared. It seems like the sensor id is not store at 0x0000 address.

On the uart log it shows this :

I am in bus test

Reading 0x0000 location of sesnor is failing

Error: Reading Sensor ID failed!

UsbEventCB: Detected SS USB Connection

USBSetupCB:In SET_FTR 0::1

USBSetupCB:In SET_FTR 0::1

USBSetupCB:In SET_FTR 0::1

UsbEventCB: SUSPEND encountered...

Entering USB Sus

Rgds

Nigel

0 Likes
KandlaguntaR_36
Moderator
Moderator

Nigel,

As per the logs, SensorRead2B is failing.

Add the following in SensorRead2B function.

apiRetStatus = CyU3PI2cReceiveBytes (&preamble, buf, 2, 0);

    CyU3PDebugPrint (4, "I2C Read Statue = %x\n\r", apiRetStatus);

Please probe the I2C lines and understand what is happening over I2C (whether there is ACK from the I2C device).

Please confirm whether the i2c slave device address is correct.

0 Likes
nich_4171101
New Contributor II

Hi Sridhar,

according to the mt9v034 image sensor data sheet the i2c slave addresss is 0x91 its correct.

pastedImage_2.png

pastedImage_1.png

0 Likes
nich_4171101
New Contributor II

Hi Sridhar,

I probed to the sckl but its seems the signal its just flat 3.4v. I'm using the AN75779 firmware change the i2c slave address according to the MT9v034.WhatsApp Image 2019-07-15 at 4.44.06 PM.jpeg

Rgds

Nigel

0 Likes
KandlaguntaR_36
Moderator
Moderator

Can you please use the I2c example firmware on explorer kit and check whether there is any activity on I2C lines?

SDK path: C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxusbi2cdmamode

0 Likes
nich_4171101
New Contributor II

Hi Sridhar,

Yes i have tested:

C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxusbi2cdmamode

The i2c lines just at 3.4v

Rgds

Nigel

0 Likes
KandlaguntaR_36
Moderator
Moderator

Please let me know your testing procedure.

Regards,

Sridhar

0 Likes
nich_4171101
New Contributor II

Hi Sridhar,

Procedure:

  1. Imported  the code from C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxusbi2cdmamode  to EZusbsuite
  2. In Ezusbsuite: Click Project-> Build all  then debug folder created.
  3. The PMODE J4 is open  short when load the code into  i2c EEPROM.
  4. Used control center to load the UsbI2cDmaMode.img which is created in the Debug folder, the UsbI2cDmaMode.img is loaded into the I2C EEPROM

Rgds

Nigel

0 Likes
KandlaguntaR_36
Moderator
Moderator

Nigel,

  1. Imported  the code from C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\firmware\serialif_examples\cyfxusbi2cdmamode  to EZusbsuite
  2. In Ezusbsuite: Click Project-> Build all  then debug folder created
  3. Place the Jumper J4 so that the device will enumerate as Cypress USB bootloader device
  4. Read the Readme.txt
  5. Open Control Center, select Control Endpoint of Bootloader device
  6. Send the Vendor Command as said in Readme.txt
  7. Probe the I2C lines while sending the Vendor command
0 Likes
nich_4171101
New Contributor II

Hi Sridhar,

I just checked on the register reference of mt9m114, the sensor id is store at R0x0000 value= 0x2481 which is same as the one in an75779pastedImage_0.png

For Mt9v034 the register reference shows the sensor id is store at R0x00 value=0x1324. Its only 8bit address instead of 16 bit.

pastedImage_1.png

Its only 8bit address instead of 16 bit. So need to change this potion to 8 bit.

pastedImage_2.png

May i know if i want to change the preamble.buffer[?], which do i need to change ?

Rgds

Nigel

0 Likes
KandlaguntaR_36
Moderator
Moderator

Nigel,

Reduce the Premable length to 3 and pass only one byte address.

Regards,

Sridhar

0 Likes
nich_4171101
New Contributor II

Hi Sridhar,

In the meantime, i will design the hardware for mt9v034 and fx-3.

  1. Do we need the ext SRAM because FX-3 already have embedded SRAM ?
  2. To store the firmware we need an EEPROM, if i follow the one in Eva board is that advisable?

Please kindly advise

0 Likes
KandlaguntaR_36
Moderator
Moderator

Nigel,

Have you test the below?

Reduce the Premable length to 3 and pass only one byte address.

Note that this needs to be done only when you are reading Sensor ID:

preamble.buffer[0] = slaveAddr & I2C_SLAVEADDR_MASK;        /*  Mask out the transfer type bit. */

    preamble.buffer[1] = lowAddr;

    preamble.buffer[2] = slaveAddr;

    preamble.length    = 3;

    preamble.ctrlMask  = 0x0003;                                /*  Send start bit after secondbyte of preamble. */

  1. Do we need the ext SRAM because FX-3 already have embedded SRAM ?

>>   Yes. You do not need it. The SRAM which is externally placed on CYUSB3KIT-003 is for demonstration of ASYNC SRAM functionality.

     2. To store the firmware we need an EEPROM, if i follow the one in Eva board is that advisable?

>> Yes, you can use the one used on Eva board. You may also use SPI Flash as well. Please refer AN76405

0 Likes
KandlaguntaR_36
Moderator
Moderator

Nigel,

Please create a new thread for a new query.

Regards,

Sridhar

0 Likes
nich_4171101
New Contributor II

Hi Sridhar,

Yes i have tested. But the sensor id read from I2c  still doesn't match the one in datasheet.

I'm using the following code:

CyU3PReturnStatus_t SensorRead2B(uint8_t slaveAddr, uint8_t lowAddr, uint8_t *buf)

{

  CyU3PReturnStatus_t apiRetStatus = CY_U3P_SUCCESS;

  CyU3PI2cPreamble_t preamble;

  if ((slaveAddr != (uint8_t)0x91) && (slaveAddr != (uint8_t)0xA1))

      {

          CyU3PDebugPrint (4, "I2C Slave address is not valid!\n");

          return 1;

      }

  preamble.buffer[0] = slaveAddr & 0xFE;  /* Slave address: Write operation */

  preamble.buffer[1] = lowAddr;

  preamble.buffer[2] = slaveAddr;      /* Slave address: Read operation */

  preamble.length = 3;

  preamble.ctrlMask = 0x0003;  // After the second byte,need to restart the I2C communication

  apiRetStatus = CyU3PI2cReceiveBytes(&preamble, buf, 2, 0);

  SensorI2CAccessDelay (apiRetStatus);

  return apiRetStatus;

}

uint8_t

SensorI2cBusTest (void)

{

    /* The sensor ID register can be read here to verify sensor connectivity. */

    uint8_t buf[2];

    CyU3PDebugPrint(4," I am in Sensor I2C bus Test API222222\r\n");

    /* Reading sensor ID */

    if (SensorRead2B (0x91, 0x00, buf) == CY_U3P_SUCCESS)

    {

        if ((buf[0] == 0x24) && (buf[1] == 0x81))

        {

        CyU3PDebugPrint(4,"Buf[0] = %x Buf[1] = %x \r\n", buf[0], buf[1]);

            return CY_U3P_SUCCESS;

        }

    }

    else

    {

    CyU3PDebugPrint(4,"Sensor Read Failed\r\n");

    CyU3PDebugPrint(4,"Buf[0] = %x Buf[1] = %x \r\n", buf[0], buf[1]);

    }

    return 1;

}

Then I used this command:

pastedImage_0.png

The UART reading:

pastedImage_1.png

Yellow: SCLK

Purple: Sdata

pastedImage_1.png

0 Likes
KandlaguntaR_36
Moderator
Moderator

Reading sensor ID issue is solved by setting proper I2C Configuration as per the sensor requirement.

View solution in original post

0 Likes