[[labs.beatcraft.com]]~
[[DE0-Nano]]~
[[Synthesijer]]~
[[DE0-Nano/Synthesijer]]~

[[DE0-Nano/Synthesijer_Samples_Serial2]]~
#Contents

* DE0-Nano/Synthesijer_Samples_Serials1 [#wdc2b781]
>
This article explains how to run a sample program, which a part of serial_echo (a set of sample programs) on DE0-Nano. Also, serial_echo is included in synthesijer _samples. In this article, this sample program is executed on the environment, which is created in the article of [[DE0-Nano/Synthesijer]].~
~
There are two sample programs in serial_echo. One sample program is EchoTest, which duplicates typed letters. The other is ToUpper, which displays all typed letters in capital. This article discusses ToUpper, which displays typed letters in upper case.~
~
Since DE0-Nano does NOT have a serial port, TX and RT are allocated to GPIO PINs. To connect to the GPIO PINs, a USB-to-UART cable is used. The cable is called C232HD-DDHSP-0, produced by FTDI Ltd, and this cable is equipped with FT232H. For the details of this cable, click the URL shown below.~
[[http://www.ftdichip.com/Support/Documents/DataSheets/Cables/DS_C232HD_UART_CABLE.PDF]]~
~
The presence of this serial connection can be checked in Teraterm on Windows.~
(This article skips the explanations for how to install Teraterm and the driver for C232HD-DDHSP-0.)~

** Modify the source files [#yb3dbf09]
>
The source files of serial_echo are modified. The details of how they are altered are shown below. This modification is strictly for DE0-Nano. We have not tested these modifications for other FPGA boards.~
~
Since the targeted FPGA board is DE0-Nano,  Makefile is changed as it is shown below.~
 $ vi Makefile
 
 VERILOG_SOURCES = $(SOURCES:.java=.v)
 
 all: hdl
 # all: hdl exstick microboard
 
 hdl: $(SOURCES)

>
sys_clk of ToUpper.java is set to 50MHz.~
 $ vi ToUpper.java
 
 public class ToUpper{
 
         private final RS232C_RX_Wrapper rx = new RS232C_RX_Wrapper("sys_clk", "50000000", "rate", "9600");
         //private final RS232C_RX_Wrapper rx = new RS232C_RX_Wrapper("sys_clk", "100000000", "rate", "9600");
         private final RS232C_TX_Wrapper tx = new RS232C_TX_Wrapper("sys_clk", "50000000", "rate", "9600");
         //private final RS232C_TX_Wrapper tx = new RS232C_TX_Wrapper("sys_clk", "100000000", "rate", "9600");
 
         public void run(){

>
After the modifications are completed, execute make.~
 $ make

>
Using DE0-Nano System Builder, create and modify the project file for ToUpper. Making the project file consist with ToUpper of synthesijer_samples, the name of project file is set for ToUpper.~
~
Move the created project file to Ubuntu. As the project file is moved, the file of ToUpper.v, which is located inside the project file, is renamed to some other names.~
clk_div.vhd, rs232c_rx.vhd, and rs232c_tx.vhd of serial_echo sample program are copied into the same directory as ToUpper.vhd 's. ToUpper.vhd is created as it is built.~
~
To consist with ToUpper.vhd, ToUpper.qsf is edited on Ubuntu.
In this article, GPIO [32] is allocated to RX, and GPIO [33] is used for TX.~
 $ vi ToUpper.qsf
 
 #============================================================
 # CLOCK
 #============================================================
 set_location_assignment PIN_R8 -to clk
 set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to clk
 # set_location_assignment PIN_R8 -to CLOCK_50
 # set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to CLOCK_50
 ...<&#30053;> 
 set_location_assignment PIN_D12 -to rx_din
 set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to rx_din
 set_location_assignment PIN_B12 -to tx_dout
 set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to tx_dout
 #set_location_assignment PIN_D12 -to GPIO[32]
 #set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to GPIO[32]
 #set_location_assignment PIN_B12 -to GPIO[33]
 #set_instance_assignment -name IO_STANDARD "3.3-V LVTTL" -to GPIO[33]
 #============================================================
 # End of pin assignments by Terasic System Builder
 #============================================================
 set_location_assignment PIN_A11 -to reset
 set_instance_assignment -name IO_STANDARD 2.5V -to reset
 set_global_assignment -name VHDL_FILE clk_div.vhd
 set_global_assignment -name VHDL_FILE rs232c_rx.vhd
 set_global_assignment -name VHDL_FILE rs232c_tx.vhd
 set_global_assignment -name VHDL_FILE ToUpper.vhd
 set_global_assignment -name STRATIX_DEVICE_IO_STANDARD "2.5 V"

>
GPIO[32] and GPIO[33] on DE0-Nano are connected to the orange lead and yellow lead of C232HD-DDHSP-0, respectively. The orange lead is TXD, and the yellow lead is RXD. The black lead, which works as GND, is attached to #12pin. #12pin is located between GPIO[07] and GPIO[09].~
~
Caution: The USB terminal of C232HD-DDHSP-0 is managed while the cable is attached to the PC.~
#ref(serial2.png,,30%); ~
~
The next step is writing the image to DE0-Nano and also called programming. The process is identical to what describes in the end part of DE0-Nano/Synthesijer_QuickStart. As starting up Quartus, execute Complication, check the allocation of PINs by Pin Planner, and write the image to DE0-Nano by Programmer.~
~
To do operation check, start up Teraterm on the Windows PC, which is connected DE0-Nano via  C232HD-DDHSP-0. Open up the COM Port, make sure that its baudrate is set to 9600. Then, please type any letters. In Teraterm, the letters that you have typed shows in upper case.~
#ref(toupper.png,,45%); ~
~
This is the end of the operation check on ToUpper of serial_echo.~

*Revision History [#gfa7b715]
>
- 2014/12/25 This article is initially uploaded~

Front page   Edit Diff Backup Upload Copy Rename Reload   New List of pages Search Recent changes   RSS of recent changes