Image feed from OV7670 is divided in half on screen?

So I have a setup where I've got the nano 33 ble sense connected to an OV7670 camera with these connections :

  - 3.3 connected to 3.3
  - GND connected GND
  - SIOC connected to A5
  - SIOD connected to A4
  - VSYNC connected to 8
  - HREF connected to A1
  - PCLK connected to A0
  - XCLK connected to 9
  - D7 connected to 4
  - D6 connected to 6
  - D5 connected to 5
  - D4 connected to 3
  - D3 connected to 2
  - D2 connected to 0 / RX
  - D1 connected to 1 / TX
  - D0 connected to 10
  - Reset connected to A2
  - PWDN connected to A3

and the nano is hooked up to an arduino due with UART as per this image :

and the arduino due is attached to a tft shield meant for the uno.

The code is as follows :

Nano -

UART NewSerial(digitalPinToPinName(11), digitalPinToPinName(12), NC, NC);

#include <Arduino_OV767X.h>

int bytesPerFrame;

byte data[176 * 144 * 2];

void setup() {
  pinMode(A2, OUTPUT);
  pinMode(A3, OUTPUT);
  digitalWrite(A2, HIGH);
  digitalWrite(A3, LOW);

  NewSerial.begin(115200);

  if (!Camera.begin(QCIF, RGB565, 1)) {
    NewSerial.println("Failed to initialize camera!");
    while (1);
  }

  bytesPerFrame = Camera.width() * Camera.height() * Camera.bytesPerPixel();

}

void loop() {
  Camera.readFrame(data);

  NewSerial.write(data, bytesPerFrame);
}

Due -

#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;

byte data[176 * 144 * 2];

int x , y , i , c;

void setup() {
  Serial1.begin(115200);
  uint16_t ID = tft.readID();
  if (ID == 0xD3) ID = 0x9481;
  tft.begin(ID);
  tft.setRotation(1);
}

void loop() {
  Serial1.readBytes(data, 50688);
  i = 0;
  for (y = 0; y <= 144; y++) {
    for (x = 0; x <= 176; x++) {
      c = data[i];
      c = c << 8;
      c = c | data[i + 1];
      tft.fillRect(x * 2, y * 2, 2, 2, c);
      i = i + 2;
    }
  }
}

So it is working ok..
But there is one problem :

As we can see the image is divided in half..
Is this because of the horrible connectors I am using?
Do I have to change the baud rate?
Is there a problem with my math?

I am not qualified enough to solve such a problem so please guide me on the path towards getting a perfect image feed.

Edit : I forgot to mention that the due's 5v pin is connected to the nano's vin pin and both boards' ground pins are connected.

Also..
WIN_20221110_16_40_29_Pro
The black pixels at the bottom of the image feed are always present..
A few of them are coloured and I can think of no logical reasons for their appearance.
I need an explanation for this..
Thanks in advance for your help!

Ok guys..
My problem was solved using < instead of <=
That was almost too easy..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.