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.
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.
// 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
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
Jacky (not verified)
Saturday, September 6, 2014 - 12:26pm
Permalink
Hello,
Hello,
Thanks for this article, actually it helped me using GPIO's.
I just bought the DE1-SoC board, but I can't really find the GPIO's schematic, the one which shows which pins are the analog and digital ones, and such... Do you know where can I find this schematic?
Much Regards.
Jacky
Mi-K
Saturday, September 6, 2014 - 1:17pm
Permalink
Hello Jacky,
Hello Jacky,
Glad to see the tutorial helped you.
You could find schematic in the DE1 CD-ROM.
In your case, you should find it inside this package: http://www.terasic.com/downloads/cd-rom/de1-soc/
Taking DE1-SoC_v.3.1.0_SystemCD.zip, for example, will give you:
Anyway, there're a lot of others stuff by clicking the right tab (Resources for example): http://www.terasic.com.tw/cgi-bin/page/archive.pl?Language=English&CategoryNo=167&No=836&PartNo=1
Enjoy.
Jacky (not verified)
Saturday, September 6, 2014 - 10:39pm
Permalink
Thanks for your fast reply Mi
Thanks for your fast reply Mi-K.
Also, thanks so much for your writings and articles in this site, it really helped understanding a lot of stuff about the DE1-SoC board.
Just wanted to ask one more question if you don't mind, Do you know a better place (better than the board's documentations and manuals) which gives tutorials or simpler articles on how to use the different peripherals and components of the DE1-SoC board?
Thanks a lot in advance.
Much Regards
Mi-K
Saturday, September 6, 2014 - 11:53pm
Permalink
Thank you for you comment
Thank you for you comment Jacky.
You could try the Altera public FTP: ftp://ftp.altera.com/up/pub/, especially the Altera_Material folder that gives somes examples depending of your Quartus version.
But to be honest there're not a lot of easy tutorials, that's why I tried to make some.
MCubbed (not verified)
Wednesday, November 26, 2014 - 2:39am
Permalink
First, I'm really thankful
First, I'm really thankful for your tutorial, the Altera lacks in tutorials, I'm a dummy in electronics so forgive me.
I want to know the pin assignments, I have Altera DE2, do I assign the GPIO[0] to the pin of the output only? and the CLOCK_24, what pin do I have to assign to it?
THanks :)
Mi-K
Wednesday, November 26, 2014 - 8:30pm
Permalink
Hello Mcubbed,
Hello Mcubbed,
I don't know exactly the DE2 pin assignments but what I'm sure it's that you must set:
There is some information in the DE2 user manual:
ftp://ftp.altera.com/up/pub/Altera_Material/12.1/Boards/DE2/DE2_User_Manual.pdf
You could find at page 36 the Expansion header description.
Each pin has a code assigned.
Each code refers to a functionnality that you can find in the tables in the same user manual or directly from this pins table:
http://www.terasic.com.tw/attachment/archive/30/DE2_Pin_Table.pdf
I agree this is not easy to get at first glance.
Wendy (not verified)
Friday, June 17, 2016 - 5:33pm
Permalink
Thanks for the tutorial.
Thanks for the tutorial.
I have a doubt, how did you know that GPIO_0[11] is GND and GPIO_0[28] is VCC?
I first thought that you configure them, but I see in the code nothing about this ports.
Thank you.
Mi-K
Saturday, June 18, 2016 - 5:26pm
Permalink
Hello Wendy,
Hello Wendy,
I took this information in the datasheet and user manuals.
Have a look in these zip files: http://www.terasic.com/downloads/cd-rom/de1-soc/.
You should find what you are looking for.
Add new comment