FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits
5892 Discussions

Communication / USB Blaster Like RS232

Altera_Forum
Honored Contributor II
2,883 Views

I have a DSP Development Kit Cyclone III, but it doesn't have a RS232 and i need comunicate with nios to acces a data for the PIOs it's posible use the Physical USB-Blaster(No the Embedded) to comunicate with My PC especifically a Matlab GUI?

0 Kudos
17 Replies
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

I have a DSP Development Kit Cyclone III, but it doesn't have a RS232 and i need comunicate with nios to acces a data for the PIOs it's posible use the Physical USB-Blaster(No the Embedded) to comunicate with My PC especifically a Matlab GUI? 

--- Quote End ---  

 

 

It is possible to use the USB-Blaster to establish a connection between the host PC and logic within the device. Altera don't make it convenient though. 

 

The JTAG-to-Avalon-MM master interface can be added to an SOPC or Qsys system. This component allows you to read or write via JTAG. 

 

Unfortunately, Altera only provides procedures to use the JTAG-to-Avalon-MM master from SystemConsole, which makes it a little trickier to use from MATLAB. You have to create a Tcl server that runs in SystemConsole, and then use sockets from MATLAB to get SystemConsole to access the hardware for you. 

 

The latest version of Quartus is required, since SystemConsole in that version has support for fileevent, which is needed to run a server. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

It is possible to use the USB-Blaster to establish a connection between the host PC and logic within the device. Altera don't make it convenient though. 

 

The JTAG-to-Avalon-MM master interface can be added to an SOPC or Qsys system. This component allows you to read or write via JTAG. 

 

Unfortunately, Altera only provides procedures to use the JTAG-to-Avalon-MM master from SystemConsole, which makes it a little trickier to use from MATLAB. You have to create a Tcl server that runs in SystemConsole, and then use sockets from MATLAB to get SystemConsole to access the hardware for you. 

 

The latest version of Quartus is required, since SystemConsole in that version has support for fileevent, which is needed to run a server. 

 

Cheers, 

Dave 

--- Quote End ---  

 

 

 

Thanks for you answer Dave, and another cuestion what is the best option for the communication serial with this Development Kit?
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

Thanks for you answer Dave, and another cuestion what is the best option for the communication serial with this Development Kit? 

--- Quote End ---  

 

 

Does it have a 100-mil header for GPIO? 

 

Buy an FTDI UM245R module from Digikey for $20 and it'll give you a USB-to-Serial interface to the board. The FPGA interfaces to the UM245R via an 8-bit parallel FIFO mode (8-bits data, and 4 control signals for the FIFO).  

 

MATLAB can then talk to the board like its a serial port. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

Does it have a 100-mil header for GPIO? 

 

Buy an FTDI UM245R module from Digikey for $20 and it'll give you a USB-to-Serial interface to the board. The FPGA interfaces to the UM245R via an 8-bit parallel FIFO mode (8-bits data, and 4 control signals for the FIFO).  

 

MATLAB can then talk to the board like its a serial port. 

 

Cheers, 

Dave 

--- Quote End ---  

 

 

So Many Thank's, Mr Dave! :)
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

It is possible to communicate with a JTAG avalon master by embedding SystemConsole within matlab, but it's tricky in 11.1 (you have to set up a lot of classpath variables etc). 

 

Or if you don't want to do that then start SystemConsole with the --server option and it will provide a single use TCP server for you.
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

Hi Wombat, 

 

--- Quote Start ---  

It is possible to communicate with a JTAG avalon master by embedding SystemConsole within matlab, but it's tricky in 11.1 (you have to set up a lot of classpath variables etc). 

 

Or if you don't want to do that then start SystemConsole with the --server option and it will provide a single use TCP server for you. 

--- Quote End ---  

 

 

Since SystemConsole in 11.1sp1 supports Tcl fileevent, it would be easier to write a Tcl server that runs under SystemConsole to provide the hardware access, and contact that from MATLAB. 

 

I have a Tcl client/server example if anyone wants it. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

I wrote a tutorial showing how to implement communications via the USB-Blaster: 

 

http://www.alterawiki.com/wiki/using_the_usb-blaster_as_an_sopc/qsys_avalon-mm_master_tutorial 

 

Enjoy! 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

I wrote a tutorial showing how to implement communications via the USB-Blaster: 

 

http://www.alterawiki.com/wiki/using_the_usb-blaster_as_an_sopc/qsys_avalon-mm_master_tutorial 

 

Enjoy! 

 

Cheers, 

Dave 

--- Quote End ---  

 

 

Thank's dwh@ovro.caltech.edu your information very useful, the tool QSYS is the evolution of SOPC, because when i open SOPC for load an design recommends utilize QSYS to create the design instead of SOPC.
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

the tool QSYS is the evolution of SOPC, because when i open SOPC for load an design recommends utilize QSYS to create the design instead of SOPC. 

--- Quote End ---  

 

 

That's right. The reason I wrote the tutorial was in part to see what differences there are between the two tools. Altera's Qsys tutorials focus on the hierarchical nature of the new tool, rather than just getting a basic design up and running.  

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

Does it have a 100-mil header for GPIO? 

 

Buy an FTDI UM245R module from Digikey for $20 and it'll give you a USB-to-Serial interface to the board. The FPGA interfaces to the UM245R via an 8-bit parallel FIFO mode (8-bits data, and 4 control signals for the FIFO).  

 

MATLAB can then talk to the board like its a serial port. 

 

Cheers, 

Dave 

--- Quote End ---  

 

 

Hi Dave, 

 

I want to plot the graph in Matlab from the results displayed on the Terminal Windows of Altera Monitor Program, I don't know how to start, I came across your post here. 

 

I have the USB-to-Serial interface module that you mentioned here, could you please tell me how to get started and could you please link me to the relevant resources as I really need it? I assume I would need to do something like iord_altera_avalon_uart_rxdata(uart_base) but I could not find further info. I wanted to do in C code. 

 

Thank you very much.
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

 

I don't know how to start 

 

--- Quote End ---  

 

Go through a NIOS II tutorial and create a "Hello World!" example. Have that example send data to a regular UART, and connect your FTDI interface to those pins. 

 

At that point you have a communications channel between your FPGA NIOS II processor, and your PC. 

 

Modify the NIOS II code so that it receives commands or data over the serial port, and then processes that data, eg., write to memory or read from memory. 

 

Write some MATLAB code to create and send the serial commands to the NIOS II processor, and then parse the response. 

 

Once you have the ability to write and read FPGA memory from MATLAB, you can then modify your FPGA code to add custom logic, eg., an FFT, and then you can send data to memory, program a DMA controller to stream it to the FFT, and stream the result back to memory, and once the FFT completes, you can read the destination memory from MATLAB and compare the result to the FFT model. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

Go through a NIOS II tutorial and create a "Hello World!" example. Have that example send data to a regular UART, and connect your FTDI interface to those pins. 

 

At that point you have a communications channel between your FPGA NIOS II processor, and your PC. 

 

Modify the NIOS II code so that it receives commands or data over the serial port, and then processes that data, eg., write to memory or read from memory. 

 

Write some MATLAB code to create and send the serial commands to the NIOS II processor, and then parse the response. 

 

Once you have the ability to write and read FPGA memory from MATLAB, you can then modify your FPGA code to add custom logic, eg., an FFT, and then you can send data to memory, program a DMA controller to stream it to the FFT, and stream the result back to memory, and once the FFT completes, you can read the destination memory from MATLAB and compare the result to the FFT model. 

 

Cheers, 

Dave 

--- Quote End ---  

 

 

Hi Dave, 

 

Thank you. I managed to get the hello world example working. 

 

I have two questions in mind: I got data from fpga to my Nios processor where I can display the values on the Terminal window in Altera Monitor Program, I am thinking that I can save these data in sdram or a file and plot these data directly from Nios in pc, why do I still need the uart? forgive my poor understanding, i know this is definitely a newbie question, please forgive 

 

The second question is , i just want to plot graph to Matlab, does it mean I just need txdata but not rxdata?  

 

The third question is, i have created uart component in Qsys, I also have Matlab coding to plot graph, but I guess I need a bridge to interconnect these two, does it have to do with iord_altera_avalon_uart_rxdata(uart_base)? Could you please link me to an example that use this command (iord_altera_avalon_uart_rxdata(uart_base))? 

 

Thanks a lot!
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

Go through a NIOS II tutorial and create a "Hello World!" example. Have that example send data to a regular UART, and connect your FTDI interface to those pins. 

 

At that point you have a communications channel between your FPGA NIOS II processor, and your PC. 

 

Modify the NIOS II code so that it receives commands or data over the serial port, and then processes that data, eg., write to memory or read from memory. 

 

Write some MATLAB code to create and send the serial commands to the NIOS II processor, and then parse the response. 

 

Once you have the ability to write and read FPGA memory from MATLAB, you can then modify your FPGA code to add custom logic, eg., an FFT, and then you can send data to memory, program a DMA controller to stream it to the FFT, and stream the result back to memory, and once the FFT completes, you can read the destination memory from MATLAB and compare the result to the FFT model. 

 

Cheers, 

Dave 

--- Quote End ---  

 

 

 

Forgive me for another question, this is the code from the manual, what I dont understand is how by running this example the code can read the data from uart since it defines the strings here (char *str = "Hello from NIOS II\n" ) but not reading directly from uart? I could not find how to read and write from/to uart. 

 

# include <stdint.h># include "system.h" 

 

int main(void) 

volatile uint32_t *uart = (volatile uint32_t*) UART_BASE; 

char *str = "Hello from NIOS II\n"; 

 

while (1) 

char *ptr = str; 

while (*ptr != '\0') 

while ((uart[2] & (1<<6)) == 0); 

uart[1] = *ptr; 

ptr++; 

 

return 0; 

}
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

 

I got data from fpga to my Nios processor where I can display the values on the Terminal window in Altera Monitor Program 

 

--- Quote End ---  

 

I have not used that tool. If it uses the JTAG-UART, then its probably not that easy to write custom software for it. Others might be able to comment. 

 

 

--- Quote Start ---  

 

I am thinking that I can save these data in sdram or a file and plot these data directly from Nios in pc, why do I still need the uart? 

 

--- Quote End ---  

 

Why think - just do it. Chances are that in the process of trying to do it, you find you cannot. That is why I recommended using a UART, since I know interfacing to that is trivial. You can access a UART directly from MATLAB. 

 

 

--- Quote Start ---  

 

i just want to plot graph to Matlab, does it mean I just need txdata but not rxdata? 

 

--- Quote End ---  

 

You'll need both. Ignore the fact that you are talking to an FPGA for a minute, and consider that you are trying to communicate between two processors; your MATLAB program is one process, and your NIOS II process is another. If you were to try to connect two PCs and have two instances of MATLAB communicate, how would you do that? First you would define a protocol, eg., lets say the protocol was to read and write data, with the read command being the string "r <address> <length>", and the write command being "w <address> <length> <data>", where address, length, and data are hexadecimal strings. Once you have that working, you can write a MATLAB script to communicate with the NIOS II processor, which in turn accesses the FPGA memory. 

 

 

--- Quote Start ---  

 

The third question is, i have created uart component in Qsys, I also have Matlab coding to plot graph, but I guess I need a bridge to interconnect these two, does it have to do with iord_altera_avalon_uart_rxdata(uart_base)? Could you please link me to an example that use this command (iord_altera_avalon_uart_rxdata(uart_base))? 

 

--- Quote End ---  

 

Sorry, I don't use NIOS II, but its "just a serial port", so work on it until you understand it. Those commands look very low-level. You should be working at a higher-level, i.e., with the C stdio library functions, but that assumes the NIOS II support library provides the hooks (stubs) to connect to the stdio functions. 

 

 

--- Quote Start ---  

 

I could not find how to read and write from/to uart 

 

--- Quote End ---  

 

You'll have to read the Altera documentation. The fact that the interface is a UART should be "hidden" from you. The interface should be the C/C++ stdio interface, or a file descriptor to the serial port. 

 

I can't really help with your NIOS II coding questions, you're better off asking a new question on the forum. Though these questions are fairly fundamental to using an embedded processor, and should be answered in Altera's documentation. So please take the time to read Altera's documentation, and run a "Hello World!" example - where you should see they use printf() not some UART command. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

Does it have a 100-mil header for GPIO? 

 

Buy an FTDI UM245R module from Digikey for $20 and it'll give you a USB-to-Serial interface to the board. The FPGA interfaces to the UM245R via an 8-bit parallel FIFO mode (8-bits data, and 4 control signals for the FIFO).  

 

MATLAB can then talk to the board like its a serial port. 

 

Cheers, 

Dave 

--- Quote End ---  

 

 

Hi Dave, 

 

I am able to read data from FPGA to Nios processor, then transmit this data to Uart component created in Qsys. 

 

Can I ask one silly question, I still do not understand why do I need FTDI UM245R module?  

 

Without FTDI UM245R module, I thought MATLAB can still talk to serial port, isn't it?? Please correct me if this is wrong. 

 

Thank you
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

 

I am able to read data from FPGA to Nios processor, then transmit this data to Uart component created in Qsys. 

 

Can I ask one silly question, I still do not understand why do I need FTDI UM245R module?  

 

Without FTDI UM245R module, I thought MATLAB can still talk to serial port, isn't it?? 

--- Quote End ---  

 

 

If you look back at the start of this thread, the person that originally asked the question indicated that their kit did not have a UART interface. 

 

If the development kit you are using has a built-in RS232 interface or USB-to-UART interface, then you do not need an FTDI device. 

 

If someone does need a USB-to-UART interface, rather than the UM245R, its possible to use FTDI breakout cables like the C232HM. The breakout cable can be connected to the 100mil headers that are present on most development kits. 

 

Cheers, 

Dave
0 Kudos
Altera_Forum
Honored Contributor II
969 Views

 

--- Quote Start ---  

If you look back at the start of this thread, the person that originally asked the question indicated that their kit did not have a UART interface. 

 

If the development kit you are using has a built-in RS232 interface or USB-to-UART interface, then you do not need an FTDI device. 

 

If someone does need a USB-to-UART interface, rather than the UM245R, its possible to use FTDI breakout cables like the C232HM. The breakout cable can be connected to the 100mil headers that are present on most development kits. 

 

Cheers, 

Dave 

--- Quote End ---  

 

 

Yes, you are right, thank you for the clarification.
0 Kudos
Reply