• 0

How to read in data using UART on Zynq PS


Question

Hi,

While there are many examples showing a basic Hello World using a Zynq UART, how do we read in data from the console using the same UART? Can anyone please guide me to the right example. I cudn't find one. 

Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi, 

One way to start would be to take a look at the examples provided by Xilinx.

You can find them at this location:

C:\Xilinx\SDK\2016.4\data\embeddedsw\XilinxProcessorIPLib\drivers\uartps_v3_3\examples

Or you can look at the "system.mss" file in SDK (bsp folder) and click on "import example".

-Sergiu

Link to post
Share on other sites
  • 0

I am able to get Hello World working over UART and printing on serial console however I cannot make my program take user input on a terminal and have the result added or multiplied. My code is as follows:

#include <stdio.h>
#include "platform.h"
#include "xil_types.h"
#include "xil_assert.h"
#include "xstatus.h"
#include "xuartps_hw.h"
#include "xplatform_info.h"
#include "xuartps.h"
#include "xil_io.h"
#include "xparameters.h"
#include "xil_types.h"
#include "xil_printf.h"

#define UART_DEVICE_ID    XPAR_XUARTPS_0_DEVICE_ID

int main()
{


XUartPs Uart_Ps;        /* The instance of the UART Driver */
init_platform();

int A,B,C;
xil_printf("enter your data\n");

A = XUartPs_RecvByte(u32 BaseAddress);
XUartPs_SendByte(u32 BaseAddress, A);
xil_printf("\r\n\r");
B = XUartPs_RecvByte(u32 BaseAddress);
xil_printf("\r\n\r");
XUartPs_SendByte(u32 BaseAddress, B);

C = A*B;

xil_printf("\n mul=");
XUartPs_SendByte(u32 BaseAddress, C);
xil_printf("\n ");

cleanup_platform();
return 0;
}

Any advice on how I could go about doing this?

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now