Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12600 Discussions

URGENT HELP re: toggle switches on DE2

Altera_Forum
Honored Contributor II
1,222 Views

Hey folks, 

 

We are working with DE2 board and are having problems with toggle switches. In our program, we used IORD_ALTERA_AVALON_... to read the input from the switch and whether it is up or down (ie 1 or 0), we are always reading 1. Not sure what the problem is. Would appreciate any positive information ASAP.  

 

Thanks.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
315 Views

I've created a design with the following components: 

Nios II/s 

Onchip memory  

- 32 KB 

PIO 0 

- 18 output only 

- Base address 8800 

- Connected to the Red LEDs 

PIO 1 

- 18 input only 

- Base address 8810 

- Connected to the Switches 

 

Ran the following code which continuously reads the switches and writes their values to the LEDs: 

#include <io.h> void main(void) {    int sw_data;    while (1)    {        sw_data = IORD_32DIRECT(0x8810, 0);        IOWR_32DIRECT(0x8800, 0, sw_data);    }    return; } 

 

Seems to work. 

 

A Common Pitfall: 

- Not assigning pins to signals in the assignment editor. 

 

 

Good luck, 

Blair
0 Kudos
Altera_Forum
Honored Contributor II
315 Views

 

--- Quote Start ---  

originally posted by theguru@Mar 20 2007, 02:49 PM 

i&#39;ve created a design with the following components: 

nios ii/s 

onchip memory  

- 32 kb 

pio 0 

- 18 output only 

- base address 8800 

- connected to the red leds 

pio 1 

- 18 input only 

- base address 8810 

- connected to the switches 

 

ran the following code which continuously reads the switches and writes their values to the leds: 

#include <io.h> void main(void) {    int sw_data;    while (1)    {        sw_data = iord_32direct(0x8810, 0);        iowr_32direct(0x8800, 0, sw_data);    }    return; } 

 

seems to work. 

 

a common pitfall: 

- not assigning pins to signals in the assignment editor. 

 

 

good luck, 

blair 

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=22367)</div> 

--- Quote End ---  

 

 

 

Thansk Blair. Will test that out and see what happens...
0 Kudos
Reply