Forum Discussion

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

Reading Input Pin

Hi, I want to read a signal from a PIN.

Everything ist fine I built it up in the SOPC Builder and declare a 8bit for Input.

I chose 8Pins in Quartus and everything wotks fine.

I can write Output to other Pins and it works also fine.

But now I want to read a Pin if it 1 or 0.

int in = IORD_ALTERA_AVALON_PIO_DATA(PIO_IN_BASE);

printf("%i\n",in);

Always they console print me 255. It doesen´t matter which PIN is on 3,3V from the Board. What I do wrong??

thx everybody for help.

4 Replies

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

    Hi,maybe i ask my question in another way.

    What must i normally do when i want to read an input pin.

    In the SOPC Builder I chose an 8bit wide input. The Pins are correct connected in the Pin planner.

    The Quartus II Software runs correct and I have communication with the Nios II Prozessor.

    What must i normally do when i want to read an input pin now??
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    IT looks like you are doing everything right. Using signaltap you can check the actual value of the 8-bti signal that you provide to the PIO, and verify that it is the value you set the pins to.

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

    And if your pins are defined as inputs with weak pull-ups (which is the default on most devices) then they will read 1 unless you connect them to ground. Connecting them to Vccio won't change their value.