UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer tish
Observer
168 Views
Registered: ‎08-20-2019

SDK code

Hello I am working on a project and I am using Zedboard. When I run this piece of code in Zedboard, the last character in the buffer gets repeated infinitely. Can anyone advice me what is the error in this code?

#include <stdio.h>
#include "xil_printf.h"
#include "xuartlite.h"
#include "xuartlite_l.h"
#include "xstatus.h"
#include "xparameters.h"
#include "xuartps.h"
#include "xgpiops.h"
#define UARTLITE_DEVICE_ID XPAR_UARTLITE_0_DEVICE_ID
#define UARTPS_DEVICE_ID XPAR_XUARTPS_0_DEVICE_ID
#define GPIO_DEVICE_ID XPAR_XGPIOPS_0_DEVICE_ID
XUartLite Uartlite;
XUartPs UartPs;
XGpioPs Gpio;
#define TEST_BUFFER_SIZE 1024 //we can use also 2048
u8 Recv[TEST_BUFFER_SIZE];
#define PIN_OFFSET 54


int main()
{
int Status;
XGpioPs_Config *Cnfg;
XUartLite_Config *Configu;
unsigned int ReceivedCount=0;
unsigned int SentCount=0;
Configu=XUartLite_LookupConfig(UARTLITE_DEVICE_ID);
Status=XUartLite_CfgInitialize(&Uartlite, Configu, Configu->RegBaseAddr);
Status=XUartLite_Initialize(&Uartlite, UARTLITE_DEVICE_ID);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
Status = XUartLite_SelfTest(&Uartlite);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
XUartPs_Config *Config;
Config = XUartPs_LookupConfig(UARTPS_DEVICE_ID);
if (NULL == Config) {
return XST_FAILURE;
}

Status = XUartPs_CfgInitialize(&UartPs, Config, Config->BaseAddress);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}

XUartPs_SetBaudRate(&UartPs, 115200);
Cnfg=XGpioPs_LookupConfig(GPIO_DEVICE_ID);
if (NULL == Cnfg) {
return XST_FAILURE;
}
Status = XGpioPs_CfgInitialize(&Gpio, Cnfg, Cnfg->BaseAddr);
if (Status != XST_SUCCESS) {
return XST_FAILURE;
}
XGpioPs_SetDirectionPin(&Gpio, PIN_OFFSET, 1);
XGpioPs_SetOutputEnablePin(&Gpio, PIN_OFFSET, 1);
while(!(Recv[TEST_BUFFER_SIZE]<=0))
{
ReceivedCount +=XUartLite_Recv(&Uartlite, Recv, 1);
for(int i=0; i<=ReceivedCount; i++)
{
SentCount +=XUartPs_Send(&UartPs, Recv, 1);
XGpioPs_WritePin(&Gpio, PIN_OFFSET, 1);
break;
}
}

return 0;
}

0 Kudos