Forum Discussion
DE2 Expansion Header
: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.17 Replies
- Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
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 - Altera_Forum
Honored Contributor
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 - Altera_Forum
Honored Contributor
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? - Altera_Forum
Honored Contributor
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. - Altera_Forum
Honored Contributor
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
Hope it helps. Tommyset_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 - Altera_Forum
Honored Contributor
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 - Altera_Forum
Honored Contributor
Did you try my example and verify that it worked for you?
- Altera_Forum
Honored Contributor
yes it works
- Altera_Forum
Honored Contributor
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?