IronDi51010
Newbie level 3
I am working with Altera DE2 board and using the NIOS IDE to load code to the processor on the board and am confused byt he example code. Input are 8 toggle switches and output is 8 leds.
I created a SOPC, with the following components:
-8 bit input, Mem. Address [0x0003000 - 0x000300f]
-8 bit output, Mem. Address [0x0003010 - 0x000301f]
-Nios II processor
-JTAG Uart interface - to communicate the computer with the board
-4 KB of onboard RAM memory
The code in the NIOS IDE:
#include "sys/alt_stdio.h"
#define Switches (volatile char*) 0x00030000
#define LEDs (char*) 0x0003010
int main()
{
alt_putstr("Hello from Nios II!\n");
/* Event loop never exits. */
while (1)
*LEDs = *Switches;
return 0;
}
The code I extracted from a guide I found, but it did not explain the code just to enter it. What I thought was happening was I mapping the output to the input. When I loaded the program all the LED's were on. No matter what the input was. Changing the value of Switches did not make any changes.
When I tried to enter in hard values of *LEDs (e.g. *LEDs = "00000000" or *LEDs = '00000000') two random leds turned on. For example using the first statement in the parentheses turned on LED 3 and 1, mean while the second statement in the parantheses turn on LED 3 and 4.
If anyone can point me in the right direction I would very much appreciate it.
I created a SOPC, with the following components:
-8 bit input, Mem. Address [0x0003000 - 0x000300f]
-8 bit output, Mem. Address [0x0003010 - 0x000301f]
-Nios II processor
-JTAG Uart interface - to communicate the computer with the board
-4 KB of onboard RAM memory
The code in the NIOS IDE:
#include "sys/alt_stdio.h"
#define Switches (volatile char*) 0x00030000
#define LEDs (char*) 0x0003010
int main()
{
alt_putstr("Hello from Nios II!\n");
/* Event loop never exits. */
while (1)
*LEDs = *Switches;
return 0;
}
The code I extracted from a guide I found, but it did not explain the code just to enter it. What I thought was happening was I mapping the output to the input. When I loaded the program all the LED's were on. No matter what the input was. Changing the value of Switches did not make any changes.
When I tried to enter in hard values of *LEDs (e.g. *LEDs = "00000000" or *LEDs = '00000000') two random leds turned on. For example using the first statement in the parentheses turned on LED 3 and 1, mean while the second statement in the parantheses turn on LED 3 and 4.
If anyone can point me in the right direction I would very much appreciate it.