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: 
Visitor ferniebola
Visitor
560 Views
Registered: ‎02-28-2019

UART Rx interrupt one event behind in Zynq 7020

Jump to solution

In a Vivado design targetting Zynq7020 I have both UART ports enabled. The purpose of my design is to forward into UART0 any character received from UART1 and vice-versa. Both UART ports are conencted to COM ports in my PC each one with a terminal open so that I can type chars. I am using the Zynq 7020 UARTs in interrupt mode and I have it almost working.

The problem that I am seeing is that the characters forwarded to the forwarding port are always one character behind. For example:

  1. If I first type the char "A" on the COM port connected to UART1; nothing appears in UART0.
  2. If then I type the char "B" on the COM port connected to UART1; the char "A" appears in UART0. 
  3. If then I type the char "C" on the COM port connected to UART1; the char "B" appears in UART0. 

The same happens if I type chars in the COM port connected to UART0: the chars appearing in UART1 are one char behind.

Why could the cause for that?

I am attaching my code; which I leveraged from the "xuartps_intr_example.c".

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
Visitor ferniebola
Visitor
372 Views
Registered: ‎02-28-2019

Re: UART Rx interrupt one event behind in Zynq 7020

Jump to solution

@pvenugo , @stephenm 

I figured it out!

I was missing the following:

  1. Disable the RX FIFO timeout.
  2. Change the RX FIFO Threshold to 1 (defaults to 8).

I am attaching my main (and only) "C" file; which works in hardware.

0 Kudos
6 Replies
Moderator
Moderator
510 Views
Registered: ‎09-12-2007

Re: UART Rx interrupt one event behind in Zynq 7020

Jump to solution

The interrupt occurs when the buffer fills. So this would be dependant of the buffer size. 

0 Kudos
Visitor ferniebola
Visitor
484 Views
Registered: ‎02-28-2019

Re: UART Rx interrupt one event behind in Zynq 7020

Jump to solution

Hello Stephenm,

Thank you for your reply.

Which buffer, the one I am passing on in the call that I show below or the system's internal uartps rx buffer? I am indicating that the buffer is of size 1. And; is there a way to force it to interrupt as soon as the buffer is not empty?

XUartPs_Recv(&UartPs0, &Uart0_Byte, 1);

It is funny that it is only missing the first interrupt but not the subsequent ones.

0 Kudos
Moderator
Moderator
406 Views
Registered: ‎07-31-2012

Re: UART Rx interrupt one event behind in Zynq 7020

Jump to solution

Hi @ferniebola ,

Did you try removing below lines in your code?

 XUartPs_Recv(&UartPs0, &Uart0_Byte, 1);
 XUartPs_Recv(&UartPs1, &Uart1_Byte, 1);
 XUartPs_Send(&UartPs0, (u8 *) "\n", 1);
 XUartPs_Send(&UartPs1, (u8 *) "\n", 1);

And later step in debug to see whats causing the issue.

Regards

Praveen


-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------
0 Kudos
Visitor ferniebola
Visitor
387 Views
Registered: ‎02-28-2019

Re: UART Rx interrupt one event behind in Zynq 7020

Jump to solution

Hello Praveen,

Thank you for your reply.

I will try what you suggest. Although; don't I have to at least have the two waiting for the interrupt to ocurr so that they receive the character as soon as it arrives?

XUartPs_Recv(&UartPs0, &Uart0_Byte, 1);
XUartPs_Recv(&UartPs1, &Uart1_Byte, 1);

Or; should I call them after the interrupt is received?

Regards,

0 Kudos
Visitor ferniebola
Visitor
380 Views
Registered: ‎02-28-2019

Re: UART Rx interrupt one event behind in Zynq 7020

Jump to solution

Hello again, Praveen.

 

I tried what you suggested and still not working but found out a few things:

  • I am expecting to get an interrupt every time that one of the UartPs devices receives a byte; but...
  • None of the available UartPs interrupts allows the system to be interrupted under such event.
  • The only interrupts related to the RX buffer are:
    • XUARTPS_IXR_RXFULL = Occurs when the RX FIFO is full
    • XUARTPS_IXR_RXEMPTY = Occurs when the RX FIFO becomes empty
    • XUARTPS_IXR_RXOVR = Occurs when the RX fifo overruns
  • There is no interrupt for when the RX FIFO is NOT empty.

So; how can I create an interrupt-based application that gets a byte every time the RX FIFO is not empty? Can this not be accomplished at all with interrupts and therefore I will be forced to go with polling instead?

It seems to me kind of silly that there is no interrupt flag for when the RX FIFO is NOT empty.

 

0 Kudos
Visitor ferniebola
Visitor
373 Views
Registered: ‎02-28-2019

Re: UART Rx interrupt one event behind in Zynq 7020

Jump to solution

@pvenugo , @stephenm 

I figured it out!

I was missing the following:

  1. Disable the RX FIFO timeout.
  2. Change the RX FIFO Threshold to 1 (defaults to 8).

I am attaching my main (and only) "C" file; which works in hardware.

0 Kudos