Download Print this page

Altera DE1-SoC Manual page 8

Computer system with nios ii
Hide thumbs Also See for DE1-SoC:

Advertisement

/********************************************************************************
* This program demonstrates the use of parallel ports in the DE1-SoC Computer
* It performs the following:
*
1. displays the SW switch values on the red lights LEDR
*
2. displays a rotating pattern on the HEX displays
*
3. if KEY[3..0] is pressed, uses the SW switches as the pattern
********************************************************************************/
int main(void)
{
/* Declare volatile pointers to I/O registers (volatile means that the locations will not be cached,
* even in registers) */
volatile int * LED_ptr
volatile int * HEX3_HEX0_ptr = (int *) 0xFF200020;
volatile int * SW_switch_ptr
volatile int * KEY_ptr
int HEX_bits = 0x0000000F;
int SW_value;
volatile int delay_count;
while (1)
{
SW_value = *(SW_switch_ptr);
*(LED_ptr) = SW_value;
if (*KEY_ptr != 0)
{
HEX_bits = SW_value;
while (*KEY_ptr != 0);
}
*(HEX3_HEX0_ptr) = HEX_bits;
/* rotate the pattern shown on the HEX displays */
if (HEX_bits & 0x80000000)
HEX_bits = (HEX_bits
else
HEX_bits = HEX_bits
for (delay_count = 100000; delay_count != 0;
}
}
8
DE1-S
C C
O
OMPUTER
= (int *) 0xFF200000;
= (int *) 0xFF200040;
= (int *) 0xFF200050;
1) 1;
1;
Figure 9. An example of C code that uses parallel ports.
S
N
II
YSTEM WITH
IOS
// red LED address
// HEX3_HEX0 address
// SW slider switch address
// pushbutton KEY address
// initial pattern for HEX displays
// volatile so C compiler does not remove loop
// read the SW slider switch values
// light up the red LEDs
// check if any KEY was pressed
// set pattern using SW values
// wait for pushbutton KEY release
// display pattern on HEX3 ... HEX0
delay_count);
Altera Corporation - University Program
For Quartus II 15.0
// delay loop
2015

Advertisement

loading
Need help?

Need help?

Do you have a question about the DE1-SoC and is the answer not in the manual?

Questions and answers