Forum Discussion

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

Outputting data to a GPIO pin??

Hello,

I'm having issues outputting data onto a GPIO pin. I wish to measure the output of a difference equation on an oscilloscope. I currently have a signal generator hooked up to the ADC pins, from there I take the values from the ADC and put it through the difference equation and the output from the difference equation goes through a PWM. Now I'm stuck at getting the PWM output onto a GPIO pin.

In the SOPC builder, I have defined a PIO as GPIO_0 and as a one bit wide outptut. From there,in my bdf file, I have an output pin labeled GPIO_0[0] connected to it. In NIOS II, I know it creates a system.h file. From there I can find the GPIO_0_BASE. So in my C code, I'm trying to write the output of the PWM to GPIO_0_BASE as follows:

IOWR(GPIO_0_BASE,0,PWM_OUT);

I hoped this would output PWM_OUT to GPIO_0[0] and then the oscilloscope could read this but it doesn't work. By the way, I'm using a DE0 Nano. I have the ADC and difference equation working, I just can't get an output on the scope. Also, I know the difference equation is working because I have printf statements in my code printing out the output from the difference equation and the ADC and I have plotted them in Excel, verifying the output I should be seeing.

Any help would be greatly appreciated!

Thank You

2 Replies

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

    Use the macros provided with the PIO instead. You include "altera_avalon_pio_regs.h" or something along those lines. If you navigate to the PIO directory in the /ip/sopc_builder installation directory you'll find the file I'm referring to in there.

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

    I have been working on an Altera Wiki page for configuring the GPIO port on the Nios II Embedded Evaluation Kit (NEEK). It is a work in progress, and I do not have any software posted yet, but it has a detailed explanation and a copy of my design files.

    You can find it at http://www.alterawiki.com/wiki/neek_gpio_(debug)_connector.

    Good luck with your designs, and I hope this helps. Please let me know.

    Fred Heineman