Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By craiglindley
#33733 Did you get this to work? I cannot find any reference for GPIO6 or 7 or 8 in the ESP8266 documentation.

anvoice wrote:Update: made some progress, though not sure if it's complete yet. Basically the GPIO_IN register on the ESP can be used to catch grab data from all 16 pins at once. Truncating the returned value from the register to the least significant byte results in the first 8 input pins, which is just right for getting the 8 data bits from the OV7670. So the following statements:

Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <IPAddress.h>

#define GPIO_IN ((volatile uint32_t*) 0x60000318)    // register contains gpio pin values of ESP8266 in read mode + some extra values (need to be truncated)
#define PCLK 8
#define HREF 9
#define VSYNC 10

WiFiClient wifi;
IPAddress server(127,0,0,1);
const char * ssid = "SSID";
const char * pass = "PASSWORD";

byte data;

void setup() {
  //Serial.begin(115200);
 
  WiFi.begin(ssid, pass);
  WiFi.config(IPAddress(192,168,1,118), IPAddress(192,168,1,1), IPAddress(255,255,255,0));
  wifi.connect(server, 8080);
  while (WiFi.status() != WL_CONNECTED) {
    delay(200);
  }
 
  pinMode(0,INPUT);
  pinMode(1,INPUT);
  pinMode(2,INPUT);
  pinMode(3,INPUT);
  pinMode(4,INPUT);
  pinMode(5,INPUT);
  pinMode(6,INPUT);
  pinMode(7,INPUT);
  pinMode(PCLK,INPUT);
  pinMode(HREF,INPUT);
  pinMode(VSYNC,INPUT); 
}

bool st = false;

void loop() {

  if (!st){
 
  while(digitalRead(VSYNC));         // wait until new frame starts
  while(!digitalRead(VSYNC)) {      // VSYNC low = frame transmitted
    //wifi.write('s');        // signals frame start
    while(digitalRead(HREF)) {    // HREF high = row transmitted
      if (digitalRead(PCLK)){    // pixel clock high = byte transmitted
        data = (byte)*GPIO_IN;    // this line truncates all but the least significant data in the returned value, which corresponds exactly to the first 8 input pins (MSbit for pin 7, LSbit for pin 0)
        while(digitalRead(PCLK));  // wait for clock to go low
      }
      wifi.write(data);  // write data during clock low
      wifi.write('\n');
    }
    wifi.write('\n');
    //wifi.write('e');      // signals frame end
  }
 
  st = true;
  }
}


There would be a need to replace the SSID and PASSWORD tokens with valid ones.
User avatar
By Vermut
#35259 Hi. Have you made any success with this? Do you use SIOC/SIOD for fine-tuning the image? Is the resulting frame data readable by any graphics software?
User avatar
By matrix866
#50522
anvoice wrote:The camera I have has no FIFO buffer, which means it can't send the frame data directly: it must be grabbed in real-time from the 8 data pins on the module. For modules with FIFO, this questions is not as relevant since they are easier to interface. I was also hoping to use the ESP to send the data directly to a computer, thus bypassing the need for a separate MCU.

Without the FIFO, the biggest question is whether the ESP has a way of grabbing all the 8 bits during the PCLK high, which amounts to sampling 8 pins every 1/16 millionths of a second, at least for VGA resolution. I don't know if that is something ESP is capable of, and I'm guessing a typical digital read is not the best answer. I'll hook it up to an oscilloscope and try to see if the speed of read is good enough for this task, but a dedicated port register (if the ESP had one) could be a better answer.



I have the FIFO version and you are saying that it's easier to interface with this model. Do you have any library working for ESP? Thank you.
User avatar
By Me-no-dev
#50526 direct register read of the GPIO takes 74nS as I have measured it a while back.
Code: Select alluint32_t gpioState = *GPIO_IN;

reading the state of GPIO16 takes lots more as it's run by the RTC clock.