Skip to content

Detailed Data Timing on Arducam SPI Bus

Test on Arduino UNO platform

We have already done a full test on the Arduino UNO platform with the 4MHZ SPI speed. (e.g: ArduCAM_MINI_5MP_Plus)

1. Check the sensor:

I2C address: write(0x78) , read(0x79) Read ID from 0x300A and 0x300B Sensor ID: 5642

data-timing-with-SPI-Bus

i2c-read-and-write-address

2. SPI test:

Write 0x55 to 0x00 address and read the value from 0x00 address.

another-i2c-address-to-test-1024x142

3. image data transfer

After start capture, we loop read the 0x41 address until the value in the address is 0x08 which means one frame is over.

4-image-data-tranfer-through-i2c-and-how-it-shows-up-on-oscilloscope-1024x186

Then we read the length of the image from 0x42 0x43 and 0x44.

readings-of-the-image-5-1024x169

Now we read the image data by setting burst mode:

First, Set the SPI CS low. And read the 0x3C address which is Burst FIFO read operation.

burst-fifo-read-operation-1024x127

Then read the image data and the head of the image is 0xFF 0xD8 and the end of the image is oxFF and 0xD9.

head-of-the-image-1-1024x134

head-of-the-image-1024x134

Code

myCAM.CS_LOW();
myCAM.set_fifo_burst();
while ( length-- )
{
  temp_last = temp;
  temp =  SPI.transfer(0x00);
  //Read JPEG data from FIFO
  if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while,
  {
    buf[i++] = temp;  //save the last  0XD9     
    //Write the remain bytes in the buffer
    myCAM.CS_HIGH();
    Serial.write(buf,i);
    is_header = false;
    i = 0;
  }  
  if (is_header == true)
  { 
    //Write image data to buffer if not full
    if (i < 256)
      buf[i++] = temp;
    else
    {
      //Write 256 bytes image data to file
      myCAM.CS_HIGH();
     Serial.write(buf,256);
     delay(5);
      i = 0;
      buf[i++] = temp;
      myCAM.CS_LOW();
      myCAM.set_fifo_burst();
    }        
  }
  else if ((temp == 0xD8) & (temp_last == 0xFF))
  {
    is_header = true;
    Serial.println(F("ACK IMG"));
    buf[i++] = temp_last;
    buf[i++] = temp;   
  } 
}

As usual, the speed of the frame is limited to the speed of the controller.

We have test our ArduCAM MINI 2MP on the STM32F103 platform and the speed of the frame can up to 15fps.