
DE1-S
O
C C
OMPUTER
S
YSTEM WITH
N
IOS
II
For Quartus II 15.0
back, causing the character to appear in the
Terminal Window
.
The source code files shown in Figures
11
and
13
are made available as part of the Altera Monitor Program. The
files can be found under the heading
sample programs
, and are identified by the name
JTAG UART
.
/********************************************************************************
* This program demonstrates use of the JTAG UART port in the DE1-SoC Computer
*
* It performs the following:
*
1. sends a text string to the JTAG UART
*
2. reads character data from the JTAG UART
*
3. echos the character data back to the JTAG UART
********************************************************************************/
.
text
/* executable code follows */
.
global
_start
_start:
/* set up stack pointer */
movia
sp, 0x03FFFFFC
/* put stack at top of SDRAM */
movia
r6, 0xFF201000
/* JTAG UART base address */
/* print a text string */
movia
r8, TEXT_STRING
LOOP:
ldb
r5, 0(r8)
beq
r5, zero, GET_JTAG
/* string is null-terminated */
call
PUT_JTAG
addi
r8, r8, 1
br
LOOP
/* read and echo characters */
GET_JTAG:
ldwio
r4, 0(r6)
/* read the JTAG UART Data register */
andi
r8, r4, 0x8000
/* check if there is new data */
beq
r8, r0, GET_JTAG
/* if no data, wait */
andi
r5, r4, 0x00ff
/* the data is in the least significant byte */
call
PUT_JTAG
/* echo character */
br
GET_JTAG
.
end
Figure 11. An example of assembly language code that uses the JTAG UART (Part
a
).
10
Altera Corporation - University Program
2015