Altera_Forum
Honored Contributor
19 years agoTerasic DE2 - GPIO-Headers won't work
Hello
I'm using the DE2 board and just wanted to implement the GPIO-Headers to connect external components. Before I begin to build own logics in VHDL and/or implement access to the ports in Linux, I'm just trying the basics, accessing the GPIOs as PIO with tutorials like the hello_led. I took the DE2_NET Image, copied it to my harddrive, removed the write protection attribute from all files, opened the SOPC-Builder and added two PIOs with 32 bit I/O Width. The first as an output port (named GPIO_0) and the second as as an input port (named GPIO_1). Then I generated the system in the SOPC-Builder and started compiling it in Quartus II 6.0. After compiling it, I checked the pinout file in the compilation report and found that the output pins of the Cyclone II chip where mapped to the according pins for GPIO correctly (GPIO_0[0] to D25, GPIO_0[1] to J22, ...). When making a new hello_led, the system.h also contains the right addresses for the two GPIOs. So I think it should work. But it does not work. e.g. writing to the green LED PIO, like in the hello_led IOWR_ALTERA_AVALON_PIO_DATA(LED_GREEN_BASE, led); everything works fine. When reading from the switch PIO and writing this to the red LED PIO like: led2=IORD_ALTERA_AVALON_PIO_DATA(SWITCH_PIO_BASE); IOWR_ALTERA_AVALON_PIO_DATA(LED_RED_BASE, led2); everything works fine. But when I connect the one PIO to the other PIO using a 40-conductor IDE-cable (red conductor showing to the top of the board on both connectors, so it's not twisted 180 degrees but correctly connected) and writing to GPIO_0, then reading from GPIO_1 and then writing this to the LEDs, like: IOWR_ALTERA_AVALON_PIO_DATA(GPIO_0_BASE, led); led2=IORD_ALTERA_AVALON_PIO_DATA(GPIO_1_BASE); IOWR_ALTERA_AVALON_PIO_DATA(LED_RED_BASE, led2); nothing happens. I also tried to configure the GPIOs as bidirectional ports. Then, depending on which I write to and which port I read from, I ged all LEDs on or all LEDs off. Then I configured both ports as output only and connected a voltmeter to the output ports. When connecting the ground cable to the ground port of the IO header and the other cable to the +5V or +3.3V pin on the header, I correctly get +5V or +3.3V. But when connecting the cable to one of the data pins, the voltmeter is stuck at +0.7V. I took the variable which carries the left/right shifting bit from the hello_led Knight Rider Lightshow and wrote it to the two GPIO Ports which where both configured as output. To see where which bit is actually 1, I also wrote the variable to the green LEDs: IOWR_ALTERA_AVALON_PIO_DATA(GPIO_0_BASE, led); IOWR_ALTERA_AVALON_PIO_DATA(GPIO_1_BASE, led); IOWR_ALTERA_AVALON_PIO_DATA(LED_GREEN_BASE, led); I also made the delay longer, so the bit is shifted in a frequency of about 1-2 seconds only. When running this program, the green LEDs are blinking slowly left-right-left-right, but none of the output pins from the GPIO gives a sign. The voltmeter does not react, all data pins are stuck on 0.7V Any idea what's going wrong here?