Interfacing OV528 with ML507

HDL's and logic cells!

Moderator: phalanx

Post Reply
Akshay
Posts: 1
Joined: Fri Aug 22, 2014 7:37 am

Interfacing OV528 with ML507

Post by Akshay » Fri Aug 22, 2014 7:45 am

Hi all..

I am working on a project in which i need to interface a camera with the OV528 (sparkfun product ID SEN-12804). I run the code exactly as it is given in the wiki example in the link below.
http://linksprite.com/wiki/index.php5?t ... L_level%29

The code works on the arduino and I recieve data but the same code does not work on the ML507.
I am out of ideas. The camera does not seem to even acknowledge the reset command on the FPGA.
I am attaching the code running on the FPGA at the end of this post...
What could be the reason??
This is intriguing.. Please help me out..
Thanks
#include <stdio.h>
#include "xstatus.h"
#include "xparameters.h"
#include "xuartlite_l.h"
#include "serial.h"
void SendResetCmd();
void SendTakePhotoCmd();
void SendReadDataCmd();
void StopTakePhotoCmd();
#define UARTLITE_BASEADDRESS XPAR_UARTLITE_0_BASEADDR
unsigned char reset[4] = {0x56,0x00,0x26,0x00};
unsigned char sendphoto[5] = {0x56,0x00,0x36,0x01,0x00};
unsigned char stopphoto[5] = {0x56,0x00,0x36,0x01,0x03};
unsigned char MH,ML;
int a=0x0000;
int main()
{

char incomingbyte;
//NewSoftSerial mySerial(4,5); //Configure pin 4 and 5 as soft serial port
int j=0,k=0,count=0; //Read Starting address

unsigned char EndFlag=0;
//unsigned char reset[4] = {0x56,0x00,0x26,0x00};
//unsigned char sendphoto[5] = {0x56,0x00,0x36,0x01,0x00};
//unsigned char stopphoto[5] = {0x56,0x00,0x36,0x01,0x03};





//void setup()
//{
// Serial.begin(19200);
// mySerial.begin(38400);
//}



SendResetCmd();
sleep(4);
//delay(4000); //After reset, wait 2-3 second to send take picture command

SendTakePhotoCmd();

//while(mySerial.available()>0)
while (!XUartLite_IsReceiveEmpty(UARTLITE_BASEADDRESS))
{
//incomingbyte=mySerial.read();
incomingbyte = XUartLite_RecvByte(UARTLITE_BASEADDRESS);
}
char b[32];

while(!EndFlag)
{
j=0;
k=0;
count=0;
SendReadDataCmd();

// delay(25);
usleep(25000);
while (!XUartLite_IsReceiveEmpty(UARTLITE_BASEADDRESS))
{
incomingbyte = XUartLite_RecvByte(UARTLITE_BASEADDRESS);
k++;
if((k>5)&&(j<32)&&(!EndFlag))
{
b[j]=incomingbyte;
if((b[j-1]==0xFF)&&(b[j]==0xD9)) //Check if the picture is over
EndFlag=1;
j++;
count++;
}
}

for(j=0;j<count;j++)
{ if(b[j]<0x10)
XUartLite_SendByte(XPAR_RS232_UART_2_BASEADDR,b[j]);
} //Send jpeg picture over the serial port

}
while(1);
return 0;

}

//Send Reset command
void SendResetCmd()
{
serXmit1(reset,4);
}

//Send take picture command
void SendTakePhotoCmd()
{
serXmit1(sendphoto,5);
}

//Read data
void SendReadDataCmd()
{
MH=a/0x100;
ML=a%0x100;
unsigned char readphoto[16] = {0x56,0x00,0x32,0x0c,0x00,0x0a,0x00,0x00,MH,ML,0x00,0x00,0x00,0x20,0x00,0x0a};
serXmit1(readphoto,16);
a+=0x20; //address increases 32,set according to buffer size
}

void StopTakePhotoCmd()
{
serXmit1(stopphoto,5);
}

Post Reply