Created
December 30, 2014 13:27
-
-
Save taylanpince/67e7bc40baba0a27b430 to your computer and use it in GitHub Desktop.
OVR7670 FIFO Read to Serial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
#include <avr/interrupt.h> | |
// | |
// RCLK 2 | |
// VSYNC 3 | |
// D0-D4 A0-A3 | |
// D5-D8 4-7 | |
// WE 8 | |
// WRST 9 | |
// RRST 10 | |
// | |
void setup() { | |
// Pins 8 - 13 | |
DDRB = DDRB | B011101; | |
// Pins A0 - A5 | |
DDRC = DDRC | B000000; | |
// Pins 0 - 7 | |
DDRD = DDRD | B00000100; | |
Serial.begin(115200); | |
while (1) { | |
cli(); //make sure interrupts are off | |
while(!(PIND & B00001000)); // Wait for high VSYNC | |
while((PIND & B00001000)); // Wait for low VSYNC | |
PORTB &= B111101; // digitalWrite(WRST, LOW); | |
delayMicroseconds(100); | |
PORTB |= B000010; // digitalWrite(WRST, HIGH); | |
PORTB |= B000001; // digitalWrite(WE, HIGH); | |
while(!(PIND & B00001000)); // Wait for high VSYNC | |
PORTB &= B000000; // digitalWrite(WE, LOW); | |
sei(); | |
digitalWrite(10, LOW); // digitalWrite(RRST, LOW) | |
PORTD &= B11111011; // digitalWrite(RCLK, LOW); | |
PORTD |= B00000100; // digitalWrite(RCLK, HIGH); | |
PORTD &= B11111011; // digitalWrite(RCLK, LOW); | |
PORTD |= B00000100; // digitalWrite(RCLK, HIGH); | |
PORTD &= B11111011; // digitalWrite(RCLK, LOW); | |
for (uint16_t i = 0; i <= 19200; i++) { | |
PORTD |= B00000100; // digitalWrite(RCLK, HIGH); | |
unsigned char data = ((PINC & B00001111) | (PIND & B11110000)); | |
Serial.write(data); | |
PORTD &= B11111011; // digitalWrite(RCLK, LOW); | |
} | |
} | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment