OV5642_MINI_5MP_PLUS JPEG header missing

  1. Where did you get the camera module(s)?
    UCTRONICS

  2. Model number of the product(s)?
    Mini 5MP Plus OV5642

  3. What hardware/platform were you working on?
    STM32

  4. Instructions you have followed. (link/manual/etc.)
    link

  5. Problems you were having?
    jpeg header missing

  6. The dmesg log from your hardware?

  7. Troubleshooting attempts you’ve made?
    Same code works for OV2642

I have successfully used the OV2462 Arducam module but I am having trouble with the 5MP version. I can’t seem to get the jpeg header to appear. Again OV2642 works fine so all hardware and SPI/I2C lines work fine and just the initialization procedures change. The module is correctly identified as the OV5642 via I2C and the 0x55 check is also successful. I have added the necessary delays that were suggested in a similar post.
Here is my init code:

comStatus ArduCAM_Init(void) {
    BYTE wr;
// OV5642
#ifdef __5MP
    Delay(500);
    wr = 0x80;
    if (!I2C_Write(CAMERA_ADDRESS, 0x3008, 1, 1, &wr))
        return camInitErr;  
    Delay(100);
    if (!wrSensorRegs16_8(OV5642_QVGA_Preview))
        return camInitErr;
    Delay(500);
    if (!wrSensorRegs16_8(OV5642_JPEG_Capture_QSXGA))
        return camInitErr;
    Delay(500);
    if (!wrSensorRegs16_8(ov5642_320x240)) //ov5642_320x240  ov5642_2592x1944
        return camInitErr;
    Delay(1000);

    wr = 0xa8;
    if (!I2C_Write(CAMERA_ADDRESS, 0x3818, 1, 1, &wr))
        return camInitErr;
    Delay(100);
    wr = 0x10;
    if (!I2C_Write(CAMERA_ADDRESS, 0x3621, 1, 1, &wr))
        return camInitErr;
    Delay(100);
    wr = 0xb0;
    if (!I2C_Write(CAMERA_ADDRESS, 0x3801, 1, 1, &wr))
        return camInitErr;
    Delay(100);
    wr = 0x08;
    if (!I2C_Write(CAMERA_ADDRESS, 0x4407, 1, 1, &wr))
        return camInitErr;
    Delay(100);
    wr = 0x00;
    if (!I2C_Write(CAMERA_ADDRESS, 0x5888, 1, 1, &wr))
        return camInitErr;
    Delay(100);
    wr = 0xFF;
    if (!I2C_Write(CAMERA_ADDRESS, 0x5000, 1, 1, &wr))
        return camInitErr;    
    
    write_reg(0x03, 0x02); // VSYNC_LEVEL_MASK
    Delay(100);
    wrSensorRegs16_8(ov5642_320x240);
    Delay(1000);
    clear_fifo_flag();
    Delay(100);
    write_reg(0x01, 0x00);
    Delay(100);
#else
// OV2642
    write_reg(0x00, 0x55);
    if (read_reg(0x00)!=0x55)
        return camInitErr;
    
    wr = 0x01;
    if (!I2C_Write(CAMERA_ADDRESS, 0xff, 0, 1, &wr))
        return camInitErr;
    wr = 0x80;    

    if (!I2C_Write(CAMERA_ADDRESS, 0x12, 0, 1, &wr))
        return camInitErr;
    if (!wrSensorRegs8_8(OV2640_JPEG_INIT))
        return camInitErr;
    if (!wrSensorRegs8_8(OV2640_YUV422))
        return camInitErr;
    if (!wrSensorRegs8_8(OV2640_JPEG))
        return camInitErr;
    
    wr = 0x01;    
    if (!I2C_Write(CAMERA_ADDRESS, 0xff, 0, 1, &wr))
        return camInitErr;
    
    wr = 0x00;    
    if (!I2C_Write(CAMERA_ADDRESS, 0x15, 0, 1, &wr))
        return camInitErr;

    if (!wrSensorRegs8_8(OV2640_1600x1200_JPEG)) //OV2640_1600x1200_JPEG  OV2640_160x120_JPEG
        return camInitErr;
#endif
    return OK;
}

thanks

Never mind, I finally figured it out. I had to also include a delay in the wrSensorRegs16_8 function.

hi.
I too am currently struggling with the header issue. Can you tell me how you solved it?
Thank you for reading

Sure, here is the function from this repo:

//I2C Array Write 16bit address, 8bit data
int ArduCAM::wrSensorRegs16_8(const struct sensor_reg reglist[])
{
unsigned int reg_addr = 0;
unsigned char reg_val = 0;
const struct sensor_reg *next = reglist;
while ((reg_addr != 0xffff) | (reg_val != 0xff)){
reg_addr = pgm_read_word(&next->reg);
reg_val = pgm_read_word(&next->val);
wrSensorReg16_8(reg_addr, reg_val);
next++;
// Add 1ms delay here
}
return 1;
}

1 Like