FPGA, SoC, And CPLD Boards And Kits
FPGA Evaluation and Development Kits

DE2 Expansion Header

Altera_Forum
Honored Contributor II
2,677 Views

:confused: Hi, 

 

I'm trying to do a parallel communication between the CycloneII of the DE2 kit and an external uC. Getting signals out of the DE2 kit on the expansion header is not a problem, but reading from the expansion header doesn't work at all. I have no problems with CycloneII inputs that are already connected with switches or pushbutton on the DE2. Is there any difference with PIO pins that we use as inputs? Is there any special configuration I have to do when I am programming (simulations works perfectly)? 

 

Thanks in advance.
0 Kudos
17 Replies
Altera_Forum
Honored Contributor II
610 Views

You'll need to provide us with a bit more information. First how do you know that it works? Have you tried keeping a constant 0 and constant 1 on all the output pins and measured that the voltage levels match your expectation? Next, try each output pin individually as it's fairly easy to get the pin assignment wrong. If all that works, the check that your uC has a common ground with the DE2 board and that it is compatible with the voltage levels on the pins. Finally, maybe the problem is with the uC. Software problem is actually the most likely, but input pins can die from abuse. 

 

Good luck.
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

I'm trying to interface to a servor motor using the  

DE1 Board Altera/Terasic Expansion Header.  

I placed the Vhdl Servo Driver Code for the UP1-Bot (from book "Rapid Prototyping of Digital Systems") into the cyclone 2C20F484C7 fpga and routed the LMotor & RMotor signals to output pins directly to the expansion header. I also routed the Vcc and Gnd from the x.gdf schematic to the expansion header. I am wondering if the series resistors in line with the expansion header pins is attenuating the PWM 20ms/2ms signals to the servos? Does Altera have any application notes in reference to a proper servo interface??? 

Plethon2 9/18/2009
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

hi,  

I am working on similar project, and could not figure out how to do. I am writing all constant 1 and measure the output voltage, but I couldn't get 3.3 V. Could you please tell me how to make it work to communicate with uC. 

Thanks
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

Thangdc01_02, please provide more information on what you did. 

 

Show us the relevant parts of the .qsf file and all of the Verilog. Also, did you double check JP1 is set to 3.3 V (rightmost position). Did you try running the Control Panel application?
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

Hi, 

 

I am doing something quite similar as to those mentioned. Can anyone provide a sample code on how to set all the pins to constant 1. I am quite new to programming expansion header and been trying multiple ways but keep getting errors.  

 

I had been using a set of code for lighting LED by flicking on the switches (just replaced the LED with the expansion header pins) but the outputs are not how I programmed it to be. Therefore, I think it's logical for me to check if I had the pin assignments correctly.  

 

Thanks in advance.
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

viliz, that's a good strategy. If you have a scope you can also use a simple trick: create a free running counter (practically impossible to get wrong) and assign the pins to different bits of the counter. Then you can correlate the pins based on the frequency. 

 

I tested this to work exactly as expected: 

 

module de2_70_demo(input iCLK_50, input iSW, output oLEDR, output GPIO_0, output GPIO_1); reg cnt; always @(posedge iCLK_50) cnt <= cnt + 1; assign GPIO_0 = iSW ? cnt : {32{cnt}}; assign GPIO_1 = ~GPIO_0; assign oLEDR = GPIO_1; endmodule  

 

set_global_assignment -name FAMILY "Cyclone II" set_global_assignment -name DEVICE EP2C70F896C6 set_global_assignment -name TOP_LEVEL_ENTITY de2_70_demo set_location_assignment PIN_AD15 -to iCLK_50 set_location_assignment PIN_C30 -to GPIO_0 set_location_assignment PIN_C29 -to GPIO_0 set_location_assignment PIN_F29 -to GPIO_0 set_location_assignment PIN_G29 -to GPIO_0 set_location_assignment PIN_F30 -to GPIO_0 set_location_assignment PIN_G30 -to GPIO_0 set_location_assignment PIN_H29 -to GPIO_0 set_location_assignment PIN_H30 -to GPIO_0 set_location_assignment PIN_J29 -to GPIO_0 set_location_assignment PIN_H25 -to GPIO_0 set_location_assignment PIN_J30 -to GPIO_0 set_location_assignment PIN_H24 -to GPIO_0 set_location_assignment PIN_E28 -to GPIO_0 set_location_assignment PIN_J25 -to GPIO_0 set_location_assignment PIN_K24 -to GPIO_0 set_location_assignment PIN_J24 -to GPIO_0 set_location_assignment PIN_K25 -to GPIO_0 set_location_assignment PIN_L22 -to GPIO_0 set_location_assignment PIN_M21 -to GPIO_0 set_location_assignment PIN_L21 -to GPIO_0 set_location_assignment PIN_M22 -to GPIO_0 set_location_assignment PIN_N22 -to GPIO_0 set_location_assignment PIN_N25 -to GPIO_0 set_location_assignment PIN_D29 -to GPIO_0 set_location_assignment PIN_N21 -to GPIO_0 set_location_assignment PIN_N24 -to GPIO_0 set_location_assignment PIN_G27 -to GPIO_1 set_location_assignment PIN_G28 -to GPIO_1 set_location_assignment PIN_H27 -to GPIO_1 set_location_assignment PIN_L24 -to GPIO_1 set_location_assignment PIN_H28 -to GPIO_1 set_location_assignment PIN_L25 -to GPIO_1 set_location_assignment PIN_K27 -to GPIO_1 set_location_assignment PIN_L28 -to GPIO_1 set_location_assignment PIN_E27 -to GPIO_0 set_location_assignment PIN_K28 -to GPIO_1 set_location_assignment PIN_L27 -to GPIO_1 set_location_assignment PIN_K29 -to GPIO_1 set_location_assignment PIN_M25 -to GPIO_1 set_location_assignment PIN_K30 -to GPIO_1 set_location_assignment PIN_M24 -to GPIO_1 set_location_assignment PIN_L29 -to GPIO_1 set_location_assignment PIN_L30 -to GPIO_1 set_location_assignment PIN_P26 -to GPIO_1 set_location_assignment PIN_P28 -to GPIO_1 set_location_assignment PIN_D28 -to GPIO_0 set_location_assignment PIN_P25 -to GPIO_1 set_location_assignment PIN_P27 -to GPIO_1 set_location_assignment PIN_M29 -to GPIO_1 set_location_assignment PIN_R26 -to GPIO_1 set_location_assignment PIN_M30 -to GPIO_1 set_location_assignment PIN_R27 -to GPIO_1 set_location_assignment PIN_P24 -to GPIO_1 set_location_assignment PIN_N28 -to GPIO_1 set_location_assignment PIN_P23 -to GPIO_1 set_location_assignment PIN_N29 -to GPIO_1 set_location_assignment PIN_E29 -to GPIO_0 set_location_assignment PIN_R23 -to GPIO_1 set_location_assignment PIN_P29 -to GPIO_1 set_location_assignment PIN_R22 -to GPIO_1 set_location_assignment PIN_P30 -to GPIO_1 set_location_assignment PIN_G25 -to GPIO_0 set_location_assignment PIN_E30 -to GPIO_0 set_location_assignment PIN_G26 -to GPIO_0 set_location_assignment PIN_AA23 -to iSW set_location_assignment PIN_AB26 -to iSW set_location_assignment PIN_W5 -to iSW set_location_assignment PIN_V10 -to iSW set_location_assignment PIN_U9 -to iSW set_location_assignment PIN_T9 -to iSW set_location_assignment PIN_L5 -to iSW set_location_assignment PIN_L4 -to iSW set_location_assignment PIN_L7 -to iSW set_location_assignment PIN_L8 -to iSW set_location_assignment PIN_AB25 -to iSW set_location_assignment PIN_AC27 -to iSW set_location_assignment PIN_AC26 -to iSW set_location_assignment PIN_AC24 -to iSW set_location_assignment PIN_AC23 -to iSW set_location_assignment PIN_AD25 -to iSW set_location_assignment PIN_AD24 -to iSW set_location_assignment PIN_AE27 -to iSW set_location_assignment PIN_AJ6 -to oLEDR set_location_assignment PIN_AK5 -to oLEDR set_location_assignment PIN_AC13 -to oLEDR set_location_assignment PIN_AB13 -to oLEDR set_location_assignment PIN_AC12 -to oLEDR set_location_assignment PIN_AB12 -to oLEDR set_location_assignment PIN_AC11 -to oLEDR set_location_assignment PIN_AD9 -to oLEDR set_location_assignment PIN_AD8 -to oLEDR set_location_assignment PIN_AJ7 -to oLEDR set_location_assignment PIN_AC14 -to oLEDG set_location_assignment PIN_W27 -to oLEDG set_location_assignment PIN_AJ5 -to oLEDR set_location_assignment PIN_W25 -to oLEDG set_location_assignment PIN_W23 -to oLEDG set_location_assignment PIN_Y27 -to oLEDG set_location_assignment PIN_Y24 -to oLEDG set_location_assignment PIN_Y23 -to oLEDG set_location_assignment PIN_AA27 -to oLEDG set_location_assignment PIN_AA24 -to oLEDG set_location_assignment PIN_AJ4 -to oLEDR set_location_assignment PIN_AK3 -to oLEDR set_location_assignment PIN_AH4 -to oLEDR set_location_assignment PIN_AJ3 -to oLEDR set_location_assignment PIN_AJ2 -to oLEDR set_location_assignment PIN_AH3 -to oLEDR set_location_assignment PIN_AD14 -to oLEDR set_global_assignment -name CYCLONEII_RESERVE_NCEO_AFTER_CONFIGURATION "USE AS REGULAR IO" set_global_assignment -name RESERVE_ASDO_AFTER_CONFIGURATION "AS INPUT TRI-STATED" set_global_assignment -name RESERVE_ALL_UNUSED_PINS "AS INPUT TRI-STATED" set_global_assignment -name RESERVE_ALL_UNUSED_PINS_NO_OUTPUT_GND "AS OUTPUT DRIVING AN UNSPECIFIED SIGNAL" set_global_assignment -name VERILOG_FILE toplevel.v  

 

Hope it helps. 

 

Tommy
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

Hi, many thanks for the codes you posted. However, there's a slight bump in my project that I can't seem to hurdle over and I would greatly appreciate if anyone could point out the mistakes I did. 

 

What I am doing is actually controlling an RC car using FPGA. So, I connect the hardware as shown in this website : http://www.jbprojects.net/articles/rc/ 

 

From the controller to the board, I decided to use header, which is where I had problems with. I wrote the code with a simple thought of logic, but I don't know if I wrote it wrongly somewhere. This is the code I came up with 

 

 

--- Quote Start ---  

input [4:0] KEY;  

output [19:0] GPIO_0;  

assign GPIO_0[10] = KEY[0];  

assign GPIO_0[12] = KEY[1];  

assign GPIO_0[14] = KEY[2];  

assign GPIO_0[16] = KEY[3];  

--- Quote End ---  

Forgive me if I am making any obvious mistakes. This is written in such a way that when the KEY is pressed, it will send a bit to the respective header pins. However, when I program it into the DE2, the header pins are '1' even when I did not press any of the KEYs.  

 

My friend and I tried another method, but was flooded with errors. The following is the code 

 

 

--- Quote Start ---  

input [4:0] KEY;  

output [19:0] GPIO_0;  

 

GPIO_0[10] = 1'b0;  

GPIO_0[12] = 1'b0;  

GPIO_0[14] = 1'b0;  

GPIO_0[16] = 1'b0;  

 

if(KEY[0]==1 && KEY[1]==1 && KEY[2]==1 && KEY[3]==1) begin 

 

GPIO_0[10] = 1'b0;  

GPIO_0[12] = 1'b0;  

GPIO_0[14] = 1'b0;  

GPIO_0[16] = 1'b0; 

 

end 

else begin 

if (!KEY[0]) 

GPIO_0[10]=1'b1; 

 

if (!KEY[1]) 

GPIO_0[12]=1'b1; 

 

if (!KEY[2]) 

GPIO_0[14]=1'b1; 

 

if (!KEY[3]) 

GPIO_0[16]=1'b1; 

 

end 

--- Quote End ---  

I hope someone can point out my mistakes if there are any. I get errors like  

 

 

--- Quote Start ---  

Error (10170): Verilog HDL syntax error at division.v(28) near text ")"; expecting ".", or an identifier 

 

--- Quote End ---  

but I am not very sure how to tackle this problem. Help? :( 

 

Many thanks in advance for the time and help
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

Did you try my example and verify that it worked for you?

0 Kudos
Altera_Forum
Honored Contributor II
610 Views

yes it works

0 Kudos
Altera_Forum
Honored Contributor II
610 Views

Thanks, the problem with your original snippet "... assign GPIO_0[10] = KEY[0];..." is almost guaranteed to be one of pin assignment. Can you show us the entire unaltered .qsf and .v file?

0 Kudos
Altera_Forum
Honored Contributor II
610 Views

 

--- Quote Start ---  

module project (KEY,GPIO_0); 

// input [3:0] SW; 

input [3:0] KEY; 

output [19:0] GPIO_0; 

 

assign GPIO_0[10] = KEY[0]; //pin 13 for KEY0 (up) 

assign GPIO_0[12] = KEY[1]; //pin 15 for KEY1 (down)  

assign GPIO_0[14] = KEY[2]; //pin 17 for KEY2 (left) 

assign GPIO_0[16] = KEY[3]; //pin 19 for KEY3 (right) 

 

endmodule 

--- Quote End ---  

 

 

 

--- Quote Start ---  

set_global_assignment -name FAMILY "Cyclone II" 

set_global_assignment -name DEVICE EP2C35F672C6 

set_global_assignment -name TOP_LEVEL_ENTITY project 

set_global_assignment -name ORIGINAL_QUARTUS_VERSION 10.0 

set_global_assignment -name PROJECT_CREATION_TIME_DATE "15:12:27 MARCH 09, 2011" 

set_global_assignment -name LAST_QUARTUS_VERSION 10.0 

set_global_assignment -name MIN_CORE_JUNCTION_TEMP 0 

set_global_assignment -name MAX_CORE_JUNCTION_TEMP 85 

set_global_assignment -name ERROR_CHECK_FREQUENCY_DIVISOR 1 

set_global_assignment -name VERILOG_FILE project.v 

set_global_assignment -name PARTITION_NETLIST_TYPE SOURCE -section_id Top 

set_global_assignment -name PARTITION_FITTER_PRESERVATION_LEVEL PLACEMENT_AND_ROUTING -section_id Top 

set_global_assignment -name PARTITION_COLOR 16764057 -section_id Top 

set_global_assignment -name LL_ROOT_REGION ON -section_id "Root Region" 

set_global_assignment -name LL_MEMBER_STATE LOCKED -section_id "Root Region" 

set_global_assignment -name STRATIX_DEVICE_IO_STANDARD "3.3-V LVTTL" 

set_location_assignment PIN_J24 -to GPIO_0[19] 

set_location_assignment PIN_J23 -to GPIO_0[18] 

set_location_assignment PIN_H24 -to GPIO_0[17] 

set_location_assignment PIN_H23 -to GPIO_0[16] 

set_location_assignment PIN_G25 -to GPIO_0[15] 

set_location_assignment PIN_K22 -to GPIO_0[14] 

set_location_assignment PIN_G24 -to GPIO_0[13] 

set_location_assignment PIN_G23 -to GPIO_0[12] 

set_location_assignment PIN_P18 -to GPIO_0[11] 

set_location_assignment PIN_N18 -to GPIO_0[10] 

set_location_assignment PIN_F26 -to GPIO_0[9] 

set_location_assignment PIN_F25 -to GPIO_0[8] 

set_location_assignment PIN_J20 -to GPIO_0[7] 

set_location_assignment PIN_J21 -to GPIO_0[6] 

set_location_assignment PIN_F23 -to GPIO_0[5] 

set_location_assignment PIN_F24 -to GPIO_0[4] 

set_location_assignment PIN_E25 -to GPIO_0[3] 

set_location_assignment PIN_E26 -to GPIO_0[2] 

set_location_assignment PIN_J22 -to GPIO_0[1] 

set_location_assignment PIN_D25 -to GPIO_0[0] 

set_location_assignment PIN_W26 -to KEY[3] 

set_location_assignment PIN_P23 -to KEY[2] 

set_location_assignment PIN_N23 -to KEY[1] 

set_location_assignment PIN_G26 -to KEY[0] 

set_global_assignment -name MISC_FILE "C:/altera/10.0/project/project.dpf" 

set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top 

--- Quote End ---  

 

 

Here you go. There are always different results when I program it into the DE2. Now that I'm home and using my PC. there's not reaction from the keys whether I press it or not, compared to previously
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

There are a couple of variations of the DE2, for example I have the DE2-70. It looks like you have the original: http://www.terasic.com.tw/cgi-bin/page/archive.pl?language=english&categoryno=53&no=30 

Assuming that, both files look correct, so perhaps GPIO_0[10] etc isn't where you think they are? 

 

As a general debugging technique, I recommend that you _also_ assign those keys to four LEDs. If you see the LEDs react to key presses as expected, then you know that 

1) your design was loaded correct and 

2) the problem isn't with the KEY input. 

 

Tommy
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

Hi there, many thanks for your help! (^^)/ Was able to learn alot. I found out what is wrong so thanks very much for your guidance during these days :)  

 

Have a great day!! XD
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

I'm curious, could you share what ultimately was the problem? 

 

Thanks 

Tommy
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

Apparently there were some shortage issues on the circuit as it was too small of a space to work on >< so it's hardware issues. I wasn't too sure what happened previously when I had no shortage issue (I believe this arise because I re-solder some of the wires) and that I couldn't get the solution either.  

 

However, since it's miraculously done, perhaps the older issue could be due to the pin assignments which I might have carelessly assigned (or perhaps seeing the wrong set of pin assignments). This is a very embarrassing mistake I've made >.< Sorry for all the trouble I made you go through :(
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

Nah, it's fine. I myself have been ramming my head against a particular problem for weeks now so I understand such frustration. 

 

The key lesson I was trying to convey was a general debugging technique (starting from a known good point and working towards the problem in small steps). 

 

Glad you got over this particular hurdle.
0 Kudos
Altera_Forum
Honored Contributor II
610 Views

Hi all, 

 

I have a DE2 board and I´m developing a project that use de Expansion Header GPIO_1 to connect two boards, so I have the follow situation : 

 

When I configure the board_2 to be a receiver and the board_1 to be a sender, all is in correctly execution (the board_1 set the GPIO_1 and the board_2 light the LEDR according the values of the pins). 

 

My problem is: when I configure the both boards like sender/receiver, the datas are not transfered through the GPIO_1 pins, even that the write happens in a different moments. 

 

Can you help me??? Do you know if a have to use a bus management??? 

 

Any idea??  

 

:confused:
0 Kudos
Reply