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: 
Highlighted
Explorer
Explorer
16,817 Views
Registered: ‎11-21-2014

UART SDK application

Jump to solution

I am developing SDK application for the UARTlite. My board design is as like this.

adfa.png

I am trying the code from the following location:

C:\Xilinx\SDK\2014.4\data\embeddedsw\XilinxProcessorIPLib\drivers\uartlite_v3_0\examples

So, I copied and tried all the codes inside the above directory, but I see nothing in the terminal.

So, I also made hello world application but still it does not show anything.

Is it due to interrupt? Previously hello world application was working but I left interrupt of UARTlite pin unconnected.

But I would like to see how data could be sent and received to the UARTlite block.

 

I am novice to SDK and I don't know how to proceed.

Please help and thanks in advance.

0 Kudos
1 Solution

Accepted Solutions
Scholar stephenm
Scholar
25,286 Views
Registered: ‎05-06-2012

Re: UART SDK application

Jump to solution

The Zynq consists of a SoC which is tightly coupled to the PL (FPGA). On the SoC there are hardened IP that can be enabled. In my last screenshot, you can see all the IP on the SoC, the ones with the tick box are the ones that are enabled. 

In your case, you have the UART enabled. If you choose the ZC702 board for example, this will be enabled by default. You can disable this if you want. 

17 Replies
Scholar sampatd
Scholar
16,807 Views
Registered: ‎09-05-2011

Re: UART SDK application

Jump to solution
What board are you using?

Have you tried using other serial terminals such as Hyperterminal, Teraterm etc.,?
0 Kudos
Explorer
Explorer
16,802 Views
Registered: ‎11-21-2014

Re: UART SDK application

Jump to solution

Hi @sampatd .  I have tried with Teraterm. The hello world application worked on both SDK terminal and also Teraterm. 

This is the code I used to run in debug configurations.

 

#include <stdio.h>
#include "platform.h"
#include "xparameters.h"
#include "xstatus.h"
#include "xuartlite.h"

#define UARTLITE_DEVICE_ID    XPAR_UARTLITE_0_DEVICE_ID
#define TEST_BUFFER_SIZE 16

int UartLitePolledExample(u16 DeviceId);

XUartLite UartLite;        /* Instance of the UartLite Device */

u8 SendBuffer[TEST_BUFFER_SIZE];    /* Buffer for Transmitting Data */
u8 RecvBuffer[TEST_BUFFER_SIZE];    /* Buffer for Receiving Data */

void print(char *str);

int main()
{
    init_platform();
    int Status;

    print("Hello World\n\r");
    xil_printf("Starting.....\r\n");
    Status = UartLitePolledExample(UARTLITE_DEVICE_ID);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    cleanup_platform();
    return 0;
}


int UartLitePolledExample(u16 DeviceId)
{
    int Status;
    unsigned int SentCount;
    unsigned int ReceivedCount = 0;
    int Index;

    /*
     * Initialize the UartLite driver so that it is ready to use.
     */
    Status = XUartLite_Initialize(&UartLite, DeviceId);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    /*
     * Perform a self-test to ensure that the hardware was built correctly.
     */
    Status = XUartLite_SelfTest(&UartLite);
    if (Status != XST_SUCCESS) {
        return XST_FAILURE;
    }

    /*
     * Initialize the send buffer bytes with a pattern to send and the
     * the receive buffer bytes to zero.
     */
    for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
        SendBuffer[Index] = Index;
        RecvBuffer[Index] = 0;
    }

    /*
     * Send the buffer through the UartLite waiting til the data can be sent
     * (block), if the specified number of bytes was not sent successfully,
     * then an error occurred.
     */
    SentCount = XUartLite_Send(&UartLite, SendBuffer, TEST_BUFFER_SIZE);
    if (SentCount != TEST_BUFFER_SIZE) {
        return XST_FAILURE;
    }

    /*
     * Receive the number of bytes which is transfered.
     * Data may be received in fifo with some delay hence we continuously
     * check the receive fifo for valid data and update the receive buffer
     * accordingly.
     */
    while (1) {
        ReceivedCount += XUartLite_Recv(&UartLite,
                       RecvBuffer + ReceivedCount,
                       TEST_BUFFER_SIZE - ReceivedCount);
        if (ReceivedCount == TEST_BUFFER_SIZE) {
            break;
        }
    }

    /*
     * Check the receive buffer data against the send buffer and verify the
     * data was correctly received.
     */
    for (Index = 0; Index < TEST_BUFFER_SIZE; Index++) {
        if (SendBuffer[Index] != RecvBuffer[Index]) {
            return XST_FAILURE;
        }
    }

    return XST_SUCCESS;
}

0 Kudos
Scholar stephenm
Scholar
16,768 Views
Registered: ‎05-06-2012

Re: UART SDK application

Jump to solution

Are you using a Xilinx board? if yes, then you can use the tools to auto connect the TX/RX ports, and this will loc the pins to the correct pins on the board.

 

If you are using a custom board, then you will need to do this yourself.

0 Kudos
Explorer
Explorer
16,745 Views
Registered: ‎11-21-2014

Re: UART SDK application

Jump to solution

Hi. I am using Xilinx Zc702 Board. My question is without using any Uartlite blocks, I can still log into serial terminal  using Xil_printf and print functions. How is this possible?

0 Kudos
Scholar stephenm
Scholar
16,739 Views
Registered: ‎05-06-2012

Re: UART SDK application

Jump to solution

There are two UART controllers on the SoC. So, Im assuming you are using one of these

0 Kudos
Explorer
Explorer
16,735 Views
Registered: ‎11-21-2014

Re: UART SDK application

Jump to solution

I also made block design without using AXI uartlite and AXI uart 16550 IPs in vivado design. Besides, I have checked with Xapp1167 which also don't have any Uart blocks, but still I can see log in terminal.

 

This is strange.

0 Kudos
Scholar stephenm
Scholar
16,725 Views
Registered: ‎05-06-2012

Re: UART SDK application

Jump to solution

when you say, you can see the log on the console. do you mean you see the STDOUT data?

Can you open your BSP, right click on the BSP, and select Board Support Package settings. Under the OS (this will either be standalone, xilkernel, freertos, linux) configuration, here you will see what the STDOUT is set to. This is where all the printf, puts, xil_printf, ect.. in your application will be output to. Is this what you meant by the log onthe console?

 

The tools will also dump info to the console, this isnt the same as the STDOUT though

0 Kudos
Explorer
Explorer
16,658 Views
Registered: ‎11-21-2014

Re: UART SDK application

Jump to solution

Hi @stephenm . Thanks a lot for your reply. I have attached screenshot of the BSP settings.

Untitledadf.png

Thanks.

0 Kudos
Scholar stephenm
Scholar
16,655 Views
Registered: ‎05-06-2012

Re: UART SDK application

Jump to solution

Ok, so here we can see the UART1 on the processing system is used.

 

Can you clarify the following:

When you make the changes ot the PS in IPI. Did you generate the output products, and export to SDK?

When you created the BSP, did you choose to use the HW exported from IPI, or the default prebuilt HW?

 

0 Kudos
Explorer
Explorer
12,283 Views
Registered: ‎11-21-2014

Re: UART SDK application

Jump to solution

Hi @stephenm . I don't know why I get uart1 in BSP stdout settings.

I did generate output products and exported the HW to sdk.

And when creating BSP, i did use the exported HW from vivado(not the prebuilt HW).

0 Kudos
Scholar stephenm
Scholar
12,251 Views
Registered: ‎05-06-2012

Re: UART SDK application

Jump to solution
Can you post the project?
0 Kudos
Explorer
Explorer
12,238 Views
Registered: ‎11-21-2014

Re: UART SDK application

Jump to solution

Here is the link to the project. I could not post archive here as it was too big.

 

https://www.dropbox.com/s/l2hi27a0228v73g/zynq_x_trigger.rar?dl=0

 

Thanks.

0 Kudos
Scholar stephenm
Scholar
12,214 Views
Registered: ‎05-06-2012

Re: UART SDK application

Jump to solution

Hey,

 

I had a quick look at your project, and I can see the UART1 is enabled in the PS:

ps_config.png

0 Kudos
Explorer
Explorer
12,208 Views
Registered: ‎11-21-2014

Re: UART SDK application

Jump to solution

Hi @stephenm . I was following the tutorial. I did not realize about this. But is this not strange that without using IP blocks like uartlite, and only enabling in processing system allows us to use UART?

 

I am new to SoC and digital designs. Could you please elaborate? This is confusing me as I thought I need to explicitly instantiate IP before I can use them.

0 Kudos
Scholar stephenm
Scholar
25,287 Views
Registered: ‎05-06-2012

Re: UART SDK application

Jump to solution

The Zynq consists of a SoC which is tightly coupled to the PL (FPGA). On the SoC there are hardened IP that can be enabled. In my last screenshot, you can see all the IP on the SoC, the ones with the tick box are the ones that are enabled. 

In your case, you have the UART enabled. If you choose the ZC702 board for example, this will be enabled by default. You can disable this if you want. 

Explorer
Explorer
12,193 Views
Registered: ‎11-21-2014

Re: UART SDK application

Jump to solution

Thanks Stephen for your patience for helping out. I very much appreciate it. Thanks

0 Kudos
Participant bbhatt
Participant
32 Views
Registered: ‎09-23-2018

Re: UART SDK application

Jump to solution
Is it possible to use this UART (in built) and receive the input as well @milan_mian
0 Kudos