Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
19 years ago

URGENT HELP re: toggle switches on DE2

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.

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    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
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- 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...