101
alt_write_word(h2p_lw_led_addr, Mask );
The Mask in this statement decides which bit in the data register of the PIO IP is high or low. The
bits in data register decide the output state of the pins connected to the LEDs. The program for the
HEX controlling is similar to the LED.
Since the linux operate system support mult-thread software. The software for this system creates
two threads one for controlling the LED and the other for controlling the HEX. We can use the
system call pthread_create to complete the job. The function is called in the main function and a
sub-thread is created. The program running in the sub-thread is to control the led flashing in a loop.
And the main-thread in the main function is to control the digital shown on the HEX changing in a
loop. The LED and HEX’s state changing at the same time when the FPGA is configured and the
software is running on HPS.
Demonstration Source Code
Build tool: Altera SoC EDS V13.0
Project directory: \Demonstration\ SoC_FPGA\HPS_LED_HEX
Quick file directory:\ Demonstration\ SoC_FPGA\HPS_LED_HEX\ quickfile
Batch File: \ Demonstration\ SoC_FPGA\HPS_LED_HEX\ quickfile \sof_dwonload\test.bat,
FPGA Configure File : HPS_LED_HEX.sof
Binary file: HPS_LED_HEX
Build app command: make ('make clean' to remove all temporal files)
Execute app command: ./ HPS_LED_HEX
D
D
e
e
m
m
o
o
n
n
s
s
t
t
r
r
a
a
t
t
i
i
o
o
n
n
S
S
e
e
t
t
u
u
p
p
Make sure Quartus II and Nios II are installed on your PC.
Connect the USB blaster cable to the USB blaster connector (J13) on the DE1_SOC board and
host PC install USB Blaster driver II if necessary.
Connect the USB cable to the USB-to-UART connector (J4) on the DE1_SOC board and host
PC.
Make sure the executable file " HPS_LED_HEX " is copied into the SD card under the
"
/home/root
" folder in Linux.
Insert the booting micro SD card into the DE1_SOC board.
Power on the DE1_SOC board.
Launch PuTTY to connect to the UART port of SoCKit board and type "
root
" to login Altera
Yocto Linux.
Execute the demo batch file “test.bat” under the \ quickfile \sof_dwonload