The Digital Protoboard is the the set of 8 switches and 8 LEDs sitting beside the breadboard. This board can be connected to the 40-pin expansion header (either JP1 or JP2) so that the Nios II processor can access these switches and LEDs.
| Device | Digital Protoboard | |||||||||||||||
| Input/Output | either | |||||||||||||||
| Address Base | JP1: 0x10000060 JP2: 0x10000070 | |||||||||||||||
| Address Map |
| |||||||||||||||
| Initialization | Set Direction Register bits of switches for input, and LEDs for output | |||||||||||||||
| Interrupts |
| |||||||||||||||
| Hardware Setup | Connect the 40-pin ribbon from the hexkeypad to either port JP1/2 on the DE2 | |||||||||||||||
| Reference | GPIO Ports |
The 8 switches on the Digital Protoboard are connected to pins 0 to 7 on the expansion header, while the 8 LEDs are connected to pins 8 to 15. These groups of 8-bits directly control each switch/LED.
.equ ADDR_JP1PORT, 0x10000060 movia r2,ADDR_JP1PORT stwio r0,4(r2) /* Set directions to input */ ldwio r3,0(r2) /* Read switch data */
.equ ADDR_JP1PORT, 0x10000060 movia r2,ADDR_JP1PORT movia r3,0x0000ff00 stwio r3,4(r2) /* Set directions to output */ movui r3,0xaa00 stwio r3,0(r2) /* Drive LEDs */
#define ProtoBoard ((volatile long *) 0x10000060)
int main()
{
// init protoboard interface directions
*(ProtoBoard+1) = 0x0000ff00; //set switch bit directions to input, LEDs to output
long temp;
while (1)
{
temp = *ProtoBoard; // Read from protoboard
*ProtoBoard = temp << 8; // Write shifted version of switch input to LEDs
}
}