- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by theguru@Mar 20 2007, 02:49 PM 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
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=22367)</div> --- Quote End --- Thansk Blair. Will test that out and see what happens...
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page