I am a newbie in hardware design(FPGA). right now we're interfacing between camera(OV0706) and zedboard using pmod RS485 as bridge. We created successfully the block design in vivado and generated bitstream file for SDK environment as input. Upon running in SDK environment. My objective is to sent a hexadecimal command and camera will give acknowledgement if the data sent is already receive.
Question
ESV
Hello Expert,
Good day!
I am a newbie in hardware design(FPGA). right now we're interfacing between camera(OV0706) and zedboard using pmod RS485 as bridge. We created successfully the block design in vivado and generated bitstream file for SDK environment as input. Upon running in SDK environment. My objective is to sent a hexadecimal command and camera will give acknowledgement if the data sent is already receive.
Your response is highly appreciated!
Thank you and Godbless!
Best regards,
EV
Here's my code below;
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xstatus.h"
#include "ps7_init.h"
#include "xscugic.h"
#include "xparameters.h"
#include "xuartlite.h"
#define TEST_BUFFER_SIZE_SEND 5
#define TEST_BUFFER_SIZE_RECV 500
u8 SendBuffer[TEST_BUFFER_SIZE_SEND] = {56, 00, 36, 01, 00}; /* Buffer for Transmit Command */
u8 RecvBuffer[TEST_BUFFER_SIZE_RECV]; /* Buffer for Receiving Data */
XUartLite UartLite; /* Instance of the UartLite Device */
int UartLitePolledExample(u32 DeviceId)
{
int Status;
/*
* Initialize the UartLite driver so that it is ready to use.
*/
Status = XUartLite_Initialize(&UartLite, DeviceId);
if (Status != XST_SUCCESS) {
xil_printf("UARTLITE DRIVER FAILED");
return XST_FAILURE;
}
/*
* Perform a self-test to ensure that the hardware was built correctly.
*/
Status = XUartLite_SelfTest(&UartLite);
if (Status != XST_SUCCESS) {
xil_printf("SELF TEST FAILED");
return XST_FAILURE;
}
return XST_SUCCESS;
}
int main()
{
unsigned char Sent_Count;
unsigned int ReceivedCount = 0;
int sentloop = 0;
int index;
int i;
init_platform(); //INITIALIZE
ps7_post_config(); //ENABLE TO PL
UartLitePolledExample(XPAR_UARTLITE_0_DEVICE_ID); //ENABLE UARTLITE
xil_printf("Start Looping....\n");
for(index = 0; index < TEST_BUFFER_SIZE_SEND; index++){
SendBuffer[index] = SendBuffer[index];
xil_printf("Send ......[%d] = %u\n" ,sentloop,SendBuffer[index]);
sentloop++;
Sent_Count = XUartLite_Send(&UartLite,SendBuffer,TEST_BUFFER_SIZE_SEND);
xil_printf("Send Count... %u\n", Sent_Count);
}
if (Sent_Count != TEST_BUFFER_SIZE_SEND){
xil_printf("Sent Failed!");
return XST_FAILURE;
}
while(1) {
ReceivedCount = XUartLite_Recv(&UartLite,RecvBuffer,TEST_BUFFER_SIZE_RECV);
xil_printf("Received count %x\n", ReceivedCount);
for(i=0; i < ReceivedCount; i++)
{
xil_printf("Received Buffer[%d] = %x\n" ,ReceivedCount,RecvBuffer);
}
}
cleanup_platform();
return XST_SUCCESS;
}
Link to comment
Share on other sites
7 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.