De2 Gpio Pin Assignment Led

  1. December 29th, 2011, 08:57 PM#1
    Join Date
    Jun 2011
    Location
    Milwaukee, WI
    Posts
    93
    Rep Power
    1

    output GPIO on DE2

    Hello I m trying to use the output GPIO on the DE2 board and cannot even get the clock to output. I have pin one out of a breakout board running through a 1k and then to Comm.

    My code was immensely simple

    GPIO_1(1) <=clock_27;

    Is there something wrong? Is there a spefic string of code I need to output anything?



    Thanks

  2. Re: output GPIO on DE2

    What is the pin assignment? Perhaps you have a typo.

    Is this a DE2, DE2-70, or DE2-115?

    Here's a snippet from my DE2 pin assignments ...

    set pin(gpio_a(0)) D25 set pin(gpio_a(1)) J22 set pin(gpio_a(2)) E26 set pin(gpio_a(3)) E25 ... set pin(gpio_b(0)) K25 set pin(gpio_b(1)) K26 set pin(gpio_b(2)) M22 set pin(gpio_b(3)) M23
    and my DE2-70

    set pin(gpio_a(0)) C30 set pin(gpio_a(1)) C29 set pin(gpio_a(2)) E28 set pin(gpio_a(3)) D29 ... set pin(gpio_b(0)) G27 set pin(gpio_b(1)) G28 set pin(gpio_b(2)) H27 set pin(gpio_b(3)) L24
    Cheers,
    Dave
    Hello I m trying to use the output GPIO on the DE2 board and cannot even get the clock to output. I have pin one out of a breakout board running through a 1k and then to Comm.

    My code was immensely simple

    GPIO_1(1) <=clock_27;

    Is there something wrong? Is there a spefic string of code I need to output anything?
  3. December 30th, 2011, 08:54 AM#3
    Join Date
    Jun 2011
    Location
    Milwaukee, WI
    Posts
    93
    Rep Power
    1

    Re: output GPIO on DE2

    The board is just a plain old DE2 board. THey have since come out with the DE2 70 board.

    I cannot get anything to output at all. I checked the Pin list and it's fine. I also checked the labeling. It is GPIO_0 or GPIO_1

    Do I assign like this?
    GPIO_1(1) <=clock_27;

    or this
    clock_27 => GPIO_1(1) ;

    Thanks

  4. Re: output GPIO on DE2

    Yep, like that.

    Perhaps clock_27 has an issue.

    Why not start with

    GPIO_1(0) <= '0'; GPIO_1(1) <= '1';
    And see if you get the two different voltage levels on your GPIO pins.

    If you don't want to probe with a voltmeter or scope, use the LEDs.

    Cheers,
    Dave
    Do I assign like this?
    GPIO_1(1) <=clock_27;

  5. Re: output GPIO on DE2

    Last edited by dwh@ovro.caltech.edu; March 10th, 2014 at 12:24 PM.
    Here's a 'basic' example for the DE2 board. Here's how to compile it:

    1) Download and unzip the file, eg., into c:/temp/de2_basic

    2) Start Quartus and select the Tcl console. If its not visible, bring it up using View->Utility Windows, Tcl console

    3) Change to the source folder, eg.,

    tcl> cd {c:/temp/de2_basic}

    (The {} pass the path to Tcl as a string, allowing it to expand correctly under Windows. Its not needed under Linux.)

    4) Build the design

    tcl> source scripts/synth.tcl

    5) Download the design.

    Pressing the buttons on the board will change the hex display values.

    Cheers,
    Dave

    EPCS programming instructions (added 3/10/14)
    1. Download de2_basic.zip 2. Unzip into c:/temp/de2_basic 3. Start Quartus 4. Select the Tcl console If the Tcl console is not visible, make it visible via View->Utility Windows->Tcl console 5. Change directory to the zip folder tcl> cd {C:\temp\de2_basic} 6. Source the synthesis script tcl> source scripts/synth.tcl The script will output the following: Synthesizing the DE2 'basic' design ----------------------------------- - Creating the Quartus work directory - Create the project 'de2' * create a new de2 project - Creating the VHDL files list - Applying constraints - Processing the design - Processing completed 7. Download the configuration using JTAG a) Plug in your DE2 board b) Start the programmer Tools->Programmer c) Check that the USB-Blaster is detected The "Hardware Setup" should have text next to it that says "USB-Blaster [USB-0]". If it has "None", then click the "Hardware Setup" button and configure the programmer to use the DE2 USB-Blaster d) Click the "Auto Detect" button in the programmer The programmer should detect an EP2C35F672 and be ready to download the file de2.sof e) Make sure the RUN/PROG button is in the RUN position f) Click the "Start" button The "basic" design connects the switches to the LEDs, and the push-button switches to the 7-segment displays. Toggle a switch and see that the LEDs change. Push a push-button and see that the 7-segment displays change. 8. EPCS programming To program the EPCS device a) Change the RUN/PROG button to PROG b) In the programmer window, change the "Mode" to "Active Serial Programming" c) Click on the "Add File" button and add the file de2.pof This adds the DE2 file to the GUI. Note that the "Device" is EPCS16. d) Check the "Program/Configure" and "Verify" check buttons The programmer will always erase the device, so the "Erase" button is optional e) Click the "Start" button. If you forgot to change the RUN/PROG button you will see the following error in the Quartus messages window: Info (209060): Started Programmer operation at Mon Mar 10 13:20:37 2014 Error (209025): Can't recognize silicon ID for device 1 Error (209012): Operation failed If you did everything correct, you will see Info (209060): Started Programmer operation at Mon Mar 10 13:20:46 2014 Info (209018): Device 1 silicon ID is 0x14 Info (209044): Erasing ASP configuration device(s) Info (209024): Programming device 1 Info (209022): Performing verification on device 1 Info (209018): Device 1 silicon ID is 0x14 Info (209011): Successfully performed operation(s) Info (209061): Ended Programmer operation at Mon Mar 10 13:21:06 2014 f) Change the PROG/RUN button back to RUN g) Cycle power Viola, the board loads the "basic" design.
  6. January 1st, 2012, 05:20 PM#6
    Join Date
    Jun 2011
    Location
    Milwaukee, WI
    Posts
    93
    Rep Power
    1

    Re: output GPIO on DE2

    Hello,

    The DE2 basic pin list is incorrect. I will not load on the machine and brings a number of errors up I cannot fix
  7. January 1st, 2012, 05:54 PM#7
    Join Date
    Jun 2011
    Location
    Milwaukee, WI
    Posts
    93
    Rep Power
    1

    Re: output GPIO on DE2

    Here is what I have been using. There is an error with the if statement and I have no idea what it is

    LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.numeric_std.all; entity DE2_top is Port( --//////////////////////// Clock Input //////////////////////// CLOCK_27 :in std_logic; -- 27 MHz CLOCK_50 :in std_logic; -- 50 MHz EXT_CLOCK :in std_logic; -- External Clock -- //////////////////////// Push Button //////////////////////// KEY :in std_logic_vector( 3 downto 0); --Pushbutton[3:0] --//////////////////////// DPDT Switch //////////////////////// SW :in std_logic_vector( 17 downto 0 ); --Toggle Switch[17:0] --//////////////////////// 7-SEG Dispaly //////////////////////// HEX0 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 0 HEX1 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 1 HEX2 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 2 HEX3 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 3 HEX4 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 4 HEX5 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 5 HEX6 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 6 HEX7 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 7 --//////////////////////////// LED //////////////////////////// LEDG :out std_logic_vector( 8 downto 0); --LED Green[8:0] LEDR :out std_logic_vector( 17 downto 0); --LED Red[17:0] --//////////////////////////// LED //////////////////////////// GPIO_0 :inout std_logic_vector(35 downto 0); GPIO_1 :inout std_logic_vector(35 downto 0) ); end DE2_top; architecture struct of DE2_top is begin -- GPIO (expansion headers) if sw(1) /= '0'then gpio_0 <= (others => 'Z'); gpio_1(0) <= '1'; gpio_1(1) <= '1'; gpio_1(2) <= '1'; gpio_1(3) <= '1'; else gpio_1(0) <= '0'; gpio_1(1) <= '0'; gpio_1(2) <= '0'; gpio_1(3) <= '0'; end if; end;

  8. Re: output GPIO on DE2

    Last edited by dwh@ovro.caltech.edu; January 1st, 2012 at 07:06 PM.
    In what way? The Tcl pin list was generated from the schematic (with minor renaming of signals).

    Note that there are several versions of the DE2 board. I recall seeing a CD release for two different revisions of board. My board will be one of the originals. I can check the board tomorrow if you'd like.

    I checked place-and-route on Quartus 11.0sp1 and it worked fine.

    What version are you using?

    Cheers,
    Dave

    PS. Here's what Quartus 11.0sp1 and 10.1 output:
    Synthesizing the DE2 'basic' design ----------------------------------- - Creating the Quartus work directory - Create the project 'de2' * create a new de2 project - Creating the VHDL files list - Applying constraints - Processing the design - Processing completed
    The DE2 basic pin list is incorrect.
    I will not load on the machine and brings a number of errors up I cannot fix

  9. Re: output GPIO on DE2

    If statements need to be inside a process. Try the following:

    LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.numeric_std.all; entity DE2_top is Port( --//////////////////////// Clock Input //////////////////////// CLOCK_27 :in std_logic; -- 27 MHz CLOCK_50 :in std_logic; -- 50 MHz EXT_CLOCK :in std_logic; -- External Clock -- //////////////////////// Push Button //////////////////////// KEY :in std_logic_vector( 3 downto 0); --Pushbutton[3:0] --//////////////////////// DPDT Switch //////////////////////// SW :in std_logic_vector( 17 downto 0 ); --Toggle Switch[17:0] --//////////////////////// 7-SEG Dispaly //////////////////////// HEX0 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 0 HEX1 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 1 HEX2 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 2 HEX3 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 3 HEX4 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 4 HEX5 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 5 HEX6 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 6 HEX7 :out std_logic_vector( 6 downto 0); --Seven Segment Digit 7 --//////////////////////////// LED //////////////////////////// LEDG :out std_logic_vector( 8 downto 0); --LED Green[8:0] LEDR :out std_logic_vector( 17 downto 0); --LED Red[17:0] --//////////////////////////// LED //////////////////////////// GPIO_0 :inout std_logic_vector(35 downto 0); GPIO_1 :inout std_logic_vector(35 downto 0) ); end DE2_top; architecture struct of DE2_top is begin -- GPIO (expansion headers) process(sw) begin -- Default state gpio_1 <= (others => 'Z'); if sw(1) /= '0'then gpio_1(3 downto 0) <= (others => '1'); else gpio_1(3 downto 0) <= (others => '0'); end if; end process; -- Unused outputs gpio_0 <= (others => 'Z'); ledr <= (others=> '0'); ledg <= (others=> '0'); hex1 <= (others => '0'); -- and so on for the other hex ports end;
    Untested of course

    Note that *all* outputs and bidirectionals must be driven; either with a logic level or tri-state. Look at the example I sent you.

    Connect the switches to the LEDs, and that'll be easier to see.



    Cheers,
    Dave
    Here is what I have been using. There is an error with the if statement and I have no idea what it is.
  10. January 2nd, 2012, 04:48 PM#10
    Join Date
    Jun 2011
    Location
    Milwaukee, WI
    Posts
    93
    Rep Power
    1

    Re: output GPIO on DE2

    Dave,

    Thanks for your help. I checked my breakout board and it works and is labeled correctly I double checked the pin list and the schematics and it is correct. Still when I hold a multi-meter across the com and 00 or 01 and flip switch 1 I see no change in voltage. Is the pin floating? I cannot get anything from the pins. Am I using the wrong comms? are certain grounds only for certain pins? This is really confusing and frustrating. Are the pins sinking only? How should I go about checking them?

    Thanks

    Bill

Similar Threads

  1. GPIO cable
    By cool_cool in forum General Altera Discussion
    Replies: 1
    Last Post: July 31st, 2011, 09:37 PM
  2. Replies: 0
    Last Post: May 3rd, 2010, 04:05 AM
  3. Replies: 0
    Last Post: March 17th, 2010, 09:15 PM
  4. Replies: 1
    Last Post: December 1st, 2009, 08:13 PM
  5. Replies: 1
    Last Post: March 1st, 2007, 12:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Forum Rules


As you certainly liked this Altera DE1 tutorial for blinking a LED on the board, you will love this one by doing the same easy thing but with GPIOs.

I'm sure you are really excited about that. So let's go.

Explanation

On the DE1 board, there are many GPIOs.

What is a GPIO? --> GPIO stands for General Purpose Input Output.

It's a group of pins that you can set to input or output individually.

It means that when a pin is set to ouput and when you send a 0 or a 1 on it, you can get this value outside the board.

And when it's input, you get data from outside.

In this tutorial we are going to use output direction.

On the DE1 board, there are 2 GPIOs:

As you can see from the video, there are two green LEDs plugged to the breadboard (on the right).

Each green LED is paired with a 150 ohm resistor.

The black wire is the GND that I've taken from GPIO_0[11] and the red wire is the VCC (+3V) taken from GPIO_0[28].

This first green LED is just here to say there is a current through the breadboard.

Then I've taken a green wire to connect the + of the second LED to the GPIO_1[0].

It could be a bit difficult to understand that, especially because on the DE1_Schematics (that you can find easily on Internet) the first pin starts from 1 and not 0.

Furthermore we use CLOCK_24[1] instead of the famous CLOCK_50.

Code

// module blink_led_gpio module blink_led_gpio( input wire [1:0] CLOCK_24, output wire [35:0] GPIO_1 ); // reg reg [32:0] counter; reg turn; // assign assign GPIO_1[0] = turn; // always always @(posedge CLOCK_24[1]) begin counter <= counter + 1; if (counter[25]) begin turn <= 1'b1; // LED turned on end else begin turn <= 1'b0; // LED turned off end end endmodule

Conclusion

After using the DE1 LEDs, you are now able to handle LEDs outside the board.

A new step for the glory.

Well done, you've made it.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *