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.

APPRO ipnc36x mt9p031 cannot output flash strobe pulse in snapshot mode sometime

Hi, everyone,

      I can switch ipnc-mt5 to snapshot mode, trigger  it and get the snapshot picture normal.

But sometimes, the image sensor cannot output flash strobe when I have set READ_MODE_1 register's STROBE bit.

following is my code,

 

int DRV_imgsSetShutterMode(Uint8 exp_mode, Uint32 exp_time, Uint8 flash, Uint8 flash_time, int gain)
{
  static Uint8 lastRegAddr[2] = {SHUTTER_WIDTH_L, GAIN_GLOBAL};
  static Uint16 lastRegValue[2];

  Uint8 regAddr[8];
  Uint16 regValue[8], read_mode_1, output_ctrl;
  Uint32 regDelay[8] = {0};
  int status, i = 0;

#if 0
  regAddr[0] = OUTPUT_CTRL;
  status = DRV_i2cRead16(&gDRV_imgsObj.i2cHndl, &regAddr[0], &output_ctrl, 1);
  if(status!=OSA_SOK) {
    OSA_ERROR("DRV_i2cRead16() output_ctrl\n");
    return status;
  }
  OSA_printf("out_ctrl:0x%x\n", output_ctrl);
#endif

  regAddr[0] = READ_MODE_1;
  status = DRV_i2cRead16(&gDRV_imgsObj.i2cHndl, &regAddr[0], &read_mode_1, 1);
  if(status!=OSA_SOK) {
    OSA_ERROR("DRV_i2cRead16() read_mode_1\n");
    return status;
  }
#if 0
    regAddr[i] = OUTPUT_CTRL;
    regValue[i] = (output_ctrl | 0x01);
    i++;
#endif

    regAddr[i] = RESTART;
    regValue[i] = 0x03;
    i++;

  if(exp_time > 0)
  {
     DRV_ImgsFrameTime *pFrame = &gDRV_imgsObj.curFrameTime;

     regAddr[i] = SHUTTER_WIDTH_L;
     regValue[i] = (exp_time*1000.0 + pFrame->shutterOverhead)/pFrame->t_row;
     if(regValue[i]<1)
        regValue[i] = 1;
     if(regValue[i]>=64*1024-1)
        regValue[i] = 64*1024 - 1;

     i++;
  }
  if(gain > 0)
  {
     regAddr[i] = GAIN_GLOBAL;
     regValue[i] = DRV_imgsCalcAgain(gain);

     i++;
  }

  switch(exp_mode)
  {
    case IMG_EXPO_MODE_ERS:

    status = DRV_i2cRead16(&gDRV_imgsObj.i2cHndl, lastRegAddr, lastRegValue, 2);

    regAddr[i] = READ_MODE_1;
    read_mode_1 |= (1 << SNAPSHOT_BITMASK);
    read_mode_1 &= ~(1 << GLOBALRESET_BITMASK);
    if(flash)
    {
       read_mode_1 |= (1 << STROBE_BITMASK);
       read_mode_1 |= flash_time;
    }
    else
    {
       read_mode_1 &= ~(1 << STROBE_BITMASK);
    }
    regValue[i] = read_mode_1;
    i++;

    regAddr[i] = RESTART;
    regValue[i] = 0x05;
    i++;

    break;
   
    case IMG_EXPO_MODE_GRR:

    status = DRV_i2cRead16(&gDRV_imgsObj.i2cHndl, lastRegAddr, lastRegValue, 2);

    regAddr[i] = READ_MODE_1;
    read_mode_1 |= (1 << SNAPSHOT_BITMASK);
    read_mode_1 |= (1 << GLOBALRESET_BITMASK);
    if(flash)
    {
       read_mode_1 |= (1 << STROBE_BITMASK);
       read_mode_1 |= flash_time;
    }
    else
    {
       read_mode_1 &= ~(1 << STROBE_BITMASK);
    }
    regValue[i] = read_mode_1;
    i++;

    regAddr[i] = RESTART;
    regValue[i] = 0x05;
    i++;

#if 0

    usleep(gain * 1000);

    regAddr[i] = RESTART;
    regValue[i] = 0x05;
    i++;
#endif

#if 0
#if 1
    regAddr[i] = READ_MODE_1;
    read_mode_1 &= ~(1 << STROBE_BITMASK);
    regValue[i] = read_mode_1;
    i++;
#endif

  {
     DRV_ImgsFrameTime *pFrame = &gDRV_imgsObj.curFrameTime;

     regAddr[i] = SHUTTER_WIDTH_L;
     regValue[i] = (1000*1000.0 + pFrame->shutterOverhead)/pFrame->t_row;
     if(regValue[i]<1)
        regValue[i] = 1;
     if(regValue[i]>=64*1024-1)
        regValue[i] = 64*1024 - 1;

     i++;
  }

    regAddr[i] = RESTART;
    regValue[i] = 0x05;
    regDelay[i] = 0;
    i++;
#endif
    break;

    case IMG_EXPO_MODE_CONT:
    default:

    regAddr[i] = lastRegAddr[0];
    regValue[i] = lastRegValue[0];
    i++;
    regAddr[i] = lastRegAddr[1];
    regValue[i] = lastRegValue[1];
    i++;

    regAddr[i] = READ_MODE_1;
    read_mode_1 &= ~(1 << SNAPSHOT_BITMASK);
    read_mode_1 &= ~(1 << STROBE_BITMASK);
    regValue[i] = read_mode_1;
    i++;
    regAddr[i] = RESTART;
    regValue[i] = 0x01;
    i++;

    DRV_imgsSetSnaping(0);

  }

  status = _DRV_i2cWrite16(&gDRV_imgsObj.i2cHndl, &regAddr[0], &regValue[0], 0, i);
//  status = _DRV_i2cWrite16(&gDRV_imgsObj.i2cHndl, &regAddr[0], &regValue[0], &regDelay[0], i);

  if(status!=OSA_SOK) {
    OSA_ERROR("DRV_i2cWrite16()\n");
    return status;
  }
  CSL_gpioClr(&gCSL_gpioHndl, 81);//GIO_ALARM_OUT);
  OSA_printf("snap em:%d, et:%d, fl:%d, ft:%d, gn:%d\n",
      exp_mode, exp_time, flash, flash_time, gain);

  return status;
}