• 0

Pmodrs232 in genesys2


Question

Hello

Im working on using a Pmodrs232(digilent version B ) to communicate with dspace and genesys2, the problem is when I use only tx and rx from a custom defind uart block in vivado, i can send a 16 byte data to computer but the dspace can only receive part of the data, normally 10 byte and with the same setup(only connect rx tx and power ground) the raspberry pi work fine, so is not the dspace problem. Further more when I send data using loop function, the data get overlap and only receive the first two. I notice the Pmodrs232 have CTS and RTS with no connection and think maybe the raspberry pi have some rules by itself that the fpga dont have, but the uartlite have no such signal for cts and rts, where can I find this signal for output? Any advice would be appreciated.

 

Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

@martin16,

Let me see if I understand you correctly ... it works fine on a raspberry pi, but struggles when you are using dspace? 

So ... you can send 16 bytes, and only receive 10?  Does it work at lower baud rates?  Is the data coming in faster than the receiver can handle it?

Here's another question, if you use a terminal program (not dspace), do you have the same problems?  I use linux, so the terminal program I would use would be minicom.  I've also written other programs that can capture data from the serial port that seem to work quite well.

If it would be valuable to you, I just finished the weekend working on simple UART demo and testing FPGA programs--a hello world program, one that waits for a line of entered text and repeats it back, and another that dumps Abraham Lincoln's Gettysburg address at full speed through a UART and then waits before doing it again.  You might find yourself able to test with these programs, if your concern is whether or not your FPGA UART is working vice dscape working.

One final thought on the hardware flow control (RTS/CTS) you asked about: if you aren't certain about it, then disable it.  I had to do this in order to get my first design running, and the handshaking protocol ... has its problems--so you might not wish to re-enable it anyway.

Hope this helps, please write back if not,

Dan

Link to post
Share on other sites
  • 0

hello dan

I use both Pi and genesys on Dspace, with pi connect to dspace the communication runs fine, but genesys have problem. I use Hterm on a PC with rs232, the data seems correct, but I cant send the data multi times like using:while(1){status=XuartLite_Send()}, it can only send the data once. And here I have used the interrupt model. If I use the poll example without interrupt the data get overlap, instead of sending 01234.. it send 010101...The baurate is 115200 on both side.

Now I solve the 10 byte receiving problem by using the XuartLite_Send twice and it can receive the other 6 at next cycle,but the while function still only send once, I dont know why. Its so bizarre. 

Thanks for the heads up on CTS, now I know it cant work without it. Is that means I cant use CTS directly with uartlite in vivado? I just connect the rx and tx to a pmod from a uartlite, is the protocol directly from uartlite fits rs232 protocol? Cause there are some info from internet say rs232 have some start bit protocol itself which didnt show at any datasheet that make it different from uart. I just little bit confuse here.

Anyway thanks for the heads up.

Edited by martin16
Link to post
Share on other sites
  • 0

@martin16,

I hope you don't mind if this discussion takes a while.  It'll take me a while to peel back all your questions, but ... I'll try.

First, let me offer you a picture of how the UART protocol works:

uart.png

I found this picture on the internet, and I love it because for being a short/simple picture to me it explains everything of the protocol.  (But ... not the RTS/CTS, or DTR/DSR handshaking ...)  The basic protocol works by sending characters, one at a time, across a wire.  Starting from the bottom up, the "wire" carries a logic level, either high or low (as shown above).  Between any two characters, the wire idles at a positive (high) voltage. 

To send a character, the UART core needs to send a series of voltages levels, all equally spaced by the baud period.  This baud period in your case is (1/115200Hz), or about 8.68uS.  The first period is the "start bit" that you asked about.  To send this, the line is set to low for one period.  After that, the line is set to your data, one bit at a time, starting from the least significant bit to the most significant bit.  At the end, you can configured the device to send parity: even, odd, mark, or space.  As I recall, mark and space are constant values, the even and odd are based upon the data you sent.  Once you send (or don't send) the parity bit, the system then idles high for one clock period.

That's the basics of the UART protocol.  The RS232 protocol as I recall is the same, with the exceptions of 1) there are potential handshaking wires allotted (these can be ignored), and 2) other wires exist to coordinate the ground voltage level and other such--these wires don't carry logic on them.  RS232 might also specify a voltage, but again--that's irrelevant to the logic you are struggling with.

Second, I think you meant to say "now I know it [RS232] can work without it [CTS]", not "can't work without it" right?

Third, I think the first thing you might wish to do if you are having the problems you outlined above is to try a different baud rate.  Does it work at 9600?  Sure, I understand, you don't want to work at 9600, but trying it at 9600 will help you and I to figure out what's going on.

Now, last, let's come back to the code you mentioned above, and let me ask this: are you waiting for the UART to complete its character before you attempt to send the next one?  A computer can often run circles around a UART, especially a slow one, and any attempt you make to send over a UART while it's busy ... well, the result is hardware dependent.  Some hardwares will drop it, others will place the request into a FIFO of limited depth.  So ... are you testing/polling to see if the UART is no longer busy and hence able to accept another character before sending one?

When you mentioned polling vs interrupts, was that a reference to the receiver in DSpace, or the transmitter on your Genesys2 board?


Dan

Link to post
Share on other sites
  • 0

Hello dan

Thanks for the well detailed information, appreciate . You are correct about the baurate, the dspace must switch to skip read operation on the receive unit in order to get the full 54 byte from 4 period cause it runs in 0.001s and the baurate cant go that high, but I still have no idea why the raspberry pi dont require this option. The interrupt is for the genesys, it apparently the example only enable the interrupt and forgot to disable it at the end , so when I use multi uart for both usb and rs232, the interrupt effect both. But I still cant get the rs232 send data multi times using loop function. I upload my code src.rar in case somebody want to take a look at it

Link to post
Share on other sites
  • 0

@martin16,

I noticed from your code that you called the printf function.  Doesn't printf also use the serial port?  And if so, does printf have the same problems?

I also notice that you turned on the transmit interrupt before anything was available to transmit.  While I'm not that familiar with microBlaze, that's a foul on a lot of systems--since the transmit interrupt will be triggered any time the UART is idle.  To avoid a constant ISR loop, the ISR routine will need to shut down the interrupt if there's no data, and then the interrupt stuff ... doesn't work like you'd like.  Perhaps their library took care of this though.  Either way, this doesn't seem to be the problem you are struggling with.

I seem from your code that you did drop your data rate from 115200 to 9600.  Did anything change as a result?  Did you stop loosing data?  If so, the problem is probably within dspace.  Are you still loosing data?  Then the problem is probably (and likely I might add) within your microBlaze code.

Dan

Link to post
Share on other sites
  • 0

Hello dan

I have used two uart, one is for communication between genesys and dspace through rs232, the other is for communication with a PC through usb, the printf function is for the usb communication,and UartLitePolledExample function is for the rs232 .I have solved the losing data problem by changing the dspace simulation period, but the while function still not working like I wish, which is sending 0 to 32 constantly to the rs232, now it only send 0 to 32 once and then stop, and all the examples from uart are only sending data once, so how could the uart update the values

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