altera_avalon_pio data remains constant
I have an altera_avalon_pio in the Platform Designer configured as 1-bit wide input. All the required signals are connected (with the slave peripheral connected to a Nios2 Processor) and the external connection is exported. In the VHDL instantiation of the Platform Designer, the export is mapped to a signal driven by a GPIO pin of mode input, on the DE10-Nano board.
In addition to the PIO, the same signal is driving an LED port of mode output (directly from VHDL). And there is one more PIO, configured as output, which is mapped to an additional LED).
Now, the GPIO pin is connected externally to a microcontroller which drives it low.
When the microcontroller is connected, the LED driven from VHDL is off, and when it's disconnected the LED is on - so far so good. However, when I read the value of the PIO register from Nios2 code, the value remains constant (0), regardless of whether the microcontroller is connected or not and if I write this value to the LED PIO, I have the same issue. For reading the value, I'm using the IORD_ALTERA_AVALON_PIO_DATA( PIO_BASE ) macro function.
I'm using the following code to read the PIO data:
while (1) { int in = IORD_ALTERA_AVALON_PIO_DATA( PIO_BASE ); printf("pio data: %d\n", in); IOWR_ALTERA_AVALON_PIO_DATA( LED_BASE, in ); usleep(1000000); }
The output from nios2-terminal is:
pio data: 0 pio data: 0 pio data: 0 pio data: 0
regardless of whether the microcontroller is connected or not.
Could you please advise what I need to do in order for the PIO data to be consistent with the state of the GPIO pin?
Can be ignored, I was using the wrong PIO_BASE in the C code..