• 0
John_Anacall

Questions about how to use UART

Question

Once again I'm sorry if I'm asking what can be considered silly questions, but I'm diving into the FPGA world by myself and I'm having serious dificulties finding documentation or examples that fit my questions.

I'm using a Cmod A7 and I want to develop a GUI to let the user define some parameters. Through what I've been researching I believe the way to do it is using UART with the micro usb of the board. I've seen some examples of UART implementations, some I found in responses here on the forum, but due to my lack of knowledge it seems to me they lack important things so I could understand them. So I'll ask two questions:

1 - I believe that if I want to let the user change some parameter, that parameter must be a register and I need to know its adress. But how do I define the adress of that register? I haven't been able to find any example for this.

2 - It seems that the Cmod A7 has two UART ports according to the XDC file, so exactly how am I supposed to use them? Will that make a diference from examples like this one?

João

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 0

@John_Anacall,

If you are just starting with FPGA's for the first time, my recommendation would be to build a UART without the micro on board.  This will help you get past your XDC questions as well.  You can find my example project doing just this thing on github.  Please consider this seriously.  FPGA's are difficult enough to deal with.  Before adding that micro, I *strongly* recommend that you learn the basics or you will quickly end up like so many other beginners with a design that doesn't work and ... unable to answer why not.

As for the micro, why would you buy a nice board (and an expensive one too) and then fill it up with the LUTs necessary to do what you could've done for only $15 with just a cheap micro?  This wasn't why you bought your FPGA board, now, was it?

But to come back and answer your question, registers are assigned typically by the bus interconnect structure.

Dan

Share this post


Link to post
Share on other sites
  • 0

Hi @John_Anacall,

I would suggest to start with a simpler design and work up to this more complex project. Here is the Cmod A7's resource center that has some demo projects and tutorials that should be helpful. I would also suggest looking at the fpga4fun. Here is a project vault post that is doing something similar to your project. Also the xdc has a transmit and receive pin for the uart as shown below.

## UART
#set_property -dict { PACKAGE_PIN J18   IOSTANDARD LVCMOS33 } [get_ports { uart_rxd_out }]; #IO_L7N_T1_D10_14 Sch=uart_rxd_out
#set_property -dict { PACKAGE_PIN J17   IOSTANDARD LVCMOS33 } [get_ports { uart_txd_in  }]; #IO_L7P_T1_D09_14 Sch=uart_txd_in

cheers,

Jon

 

 

Share this post


Link to post
Share on other sites
  • 0

@D@n thank you, I'm definetely going to read those links (already read the ones about begginers and I totally can see myself in it). And the reason why I'm working with a FPGA is because my instructor wants me to use one in my thesis, with a microcontroller it would be much easier and probably would be done by now.

@zygot before I've made this post I used the search option, I suppose that section also shows on the search results so I haven't found any post that helped me.

@jpeyron my second point was exactly that two pins, I may have not be clear enough. And I was wondering how that two pins would make a difference from other UART examples

Share this post


Link to post
Share on other sites
  • 0

@John_Anacall,

One of the sad realities of a serial port is that one chips receiver is another's transmitter.  Sometimes when the schematic calls it a receiver, it's a transmitter with respect to the FPGA chip, other times it's a receiver.  Perhaps there's a way to know this answer by looking a the board, but I've made this as a mistake *so* many times, that I tend to use the "Hello World" demonstration program/design first (right after blinky) to make certain I have the transmit pin right before going farther.

Reading over your post above, and your desire to build a GUI, my approach to FPGA's has always been through what I call a "debugging bus".  This allows my software to interact with the FPGA by issuing read and write commands from c++ to register regions that I define on the FPGA.  I have then used this link in the past to build a GUI, although it was terribly slow.  (I was using the GUI to test an FFT with better frequency resolution--other than the speed, it worked quite well)

One of the difficulties you will see across this forum with using the MicroBlaze microcontroller, is that 1) there are only a limited number of caned demos, 2) going beyond the canned demos isn't very clear, and 3) it's very difficult to debug when things go wrong--especially since you have no insight into what the micro is doing.  On the other hand, if you started with an open source microcontroller, you'd have everything at your fingertips in order to debug it.  You might even just run the whole thing in a simulator, and then see *EVERY* wire running through it.  Just something to think about.

Let me try explaining this another way.  If you are familiar with software, and have a strong software background (it sounds like you do), then you can usually debug things via printf.  FPGA's, however, are notoriously difficult to debug by printf.  Yes, it is possible to debug the micro by printf---but not until 1) you have it up and running, and 2) your peripherals are work.  As an example, on a recent design I was working on I messed up the the connection between a component and the system bus.  I say this to point out that it isn't that uncommon.  (I use WB bus, not an AXI bus, but bugs are not unique to WB)  All of a sudden the design stopped responding to me, the serial port wouldn't work, and I had only the power button to fall back on.  What was wrong with my design?  Debug by printf wouldn't work.  Debugging via other tools did, however.

Just ... giving you some things to think about,

Dan

Share this post


Link to post
Share on other sites
  • 0
4 hours ago, John_Anacall said:

the reason why I'm working with a FPGA is because my instructor wants me to use one in my thesis, with a microcontroller it would be much easier and probably would be done by now.

Well perhaps. But this comment does put a different perspective on things. I guess that I'm having a hard time conceptualizing what your CMOD-A7 platform design consists of if you are not doing HDL. Could it be that your instructor believes that FPGA development is a software project? I'd certainly argue against such a proposition.

The UART is historically tied to the RS-232 interface standard which is funky and problematic at best. In the CMOD-A7 demo project that I posted in the Project Vault I name the VHDL toplevel UART interface pin names uart_txd_in and uart_rxd_out because it is confusing as to who is actually driving these pins. The answer  is that the UART is from the perspective of the FT2232HQ USB device where the Txd pin is an output. The schematic for the CMOD-A7 uses the same nomenclature but isn't very helpful as the page where the FT2232HQ is supposed to be is blank.

For most USB UART applications you only need the Txd and Rxd signals without flow control and if you use an external USB UART cable or interface board you can assign these to any two pins ( you will also need a digital ground reference ). For someone hoping to complete a project using a platform requiring a whole level of skills unnecessary to the job I feel your pain. The alternative to writing/debugging VHDL or Verilog is to take the preferred Xilinx GUI board design approach. As someone who has used that and prefers HDL I don't agree that doing this and adding a Microblaze is necessarily easier or quicker.

Because of issues with the CMOD-A7 drivers and Vivado hardware Manager I use an external USB UART cable almost exclusively; but that's another topic.

Edited by zygot

Share this post


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