11-08-2008 05:22 AM
Good morning
Based on the code and the ucf below,
CODE
#include "xparameters.h"
#include "xgpio_l.h"
}
UCF
Net sys_clk LOC=AJ15;
Net sys_clk IOSTANDARD = LVCMOS25;
## System level constraints
Net sys_clk PERIOD = 10000 ps;
## FPGA pin constraints
Net leds<0> LOC=AC4;
Net leds<0> IOSTANDARD = LVTTL;
Net leds<1> LOC=AC3;
Net leds<1> IOSTANDARD = LVTTL;
Net leds<2> LOC=AA6;
Net leds<2> IOSTANDARD = LVTTL;
Net leds<3> LOC=AA5;
Net leds<3> IOSTANDARD = LVTTL;
Net RX LOC=AJ8;
Net RX IOSTANDARD = LVCMOS25;
Net TX LOC=AE7;
Net TX IOSTANDARD = LVCMOS25;
Question
1) How can I write a code for ALL the LED to blink for certain time?
2) How can I write a code to blink all the LED one at a time? Instead of writing shifting LED code, is there any other way to write the code?
Thank you.
11-10-2008 02:10 PM
1) How can I write a code for ALL the LED to blink for certain time?
You could use a simple for loop and could then control the "certain time" based on the number of times you loop through the code:
example:
for (count = 0; count < count_size; count ++){
}
2) How can I write a code to blink all the LED one at a time? Instead of writing shifting LED code, is there any other way to write the code?
There are some great examples that can be found in the $XILINX_EDK\sw\XilinxProcessorIPLib\drivers\gpio_v2_12_a\examples. The xgpio_example.c source code for instance should do what you are looking to do. You can simply edit line 54 to suit the number led's for your GPIO:
line 54 - #define LED 0x01 /* Assumes bit 0 of GPIO is connected to an LED */
11-10-2008 05:37 PM
Good morning sir ,
Thank you for your reply. I am employing using microblaze processor in ML401 FPGA. I focus more on the expansion header. Because my project is based on traffic lights, I want to connect an external white board to the Expansion Header. Using XPS , I know that the LED IP’s ucf pin LOC is generated automatically, as shown below.
Net fpga_0_LEDs_4Bit_GPIO_IO_pin<0> LOC=G5;
Net fpga_0_LEDs_4Bit_GPIO_IO_pin<0> IOSTANDARD = LVCMOS25;
Net fpga_0_LEDs_4Bit_GPIO_IO_pin<0> PULLUP;
Net fpga_0_LEDs_4Bit_GPIO_IO_pin<0> SLEW = SLOW;
Net fpga_0_LEDs_4Bit_GPIO_IO_pin<0> DRIVE = 2;
Net fpga_0_LEDs_4Bit_GPIO_IO_pin<0> TIG;
But if I want to use Expansion Header, I need to write by myself. I only know how to find LOC (in ug080.pdf) .
1)But where do I get the other details? Is it necessary for me to insert the other details?
This is a code that I found in the internet
#include "xgpio.h"
#include "xparameters.h"
int main(void)
{
XGpio gp_out;
int i = 0;
int j = 0; XGpio_Initialize(&gp_out, XPAR_LEDS_4BIT_DEVICE_ID);
XGpio_SetDataDirection (&gp_out, 1, 0x0); while (1)
{
j = (j + 1) % 256; //write the value of j to the LED's
XGpio_DiscreteWrite (&gp_out, 1, j); //software delay loop for pause
for (i=0; i<4000; i++);
}
}
I do not understand why j = (j + 1) % 256; is written? I want to use Expansion Header to display extra LED (I will connect it with an external white board). If I want to trigger pin
Header_Pin | Label | FPGA_Pin |
J6, Pin2 | HDR1_28 | AA24 |
J6, Pin6 | HDR1_36 | AC25 |
If I get input 1 from UART, I want to trigger the first Header_Pin , and if I get 2, I want to trigger the second Header_Pin. I will be dealing with 12 Expansion Headers. For example, like say the Header_Pin2 (J6) is define as 0x01, then I just want to trigger it by just inserting 0x01 in the function.
2) How can I write this code to trigger Header_Pin without shifting it or calculating it? What GPIO function should I apply?
In your reply, you stated that gpio_v2_12_a examples. I went to gpio_v2_11_a examples and I saw the code that you mentioned. They define LED as 0x01 .
3) What hexadecimal number should I use to define the Expansion Header pins? Where I can get this hexadecimal number information?
Do you have sample example that can guide me ? I am not from engineering background. I am very new to FPGA world, so please explain to me in a simple way. Please reply to me as soon as possible
Thank you .
Your Help is really being appreciated
11-10-2008 09:22 PM
Good morning sir ,
Thank you for your reply. I am employing using microblaze processor in ML401 FPGA. I focus more on the expansion header. Because my project is based on traffic lights, I want to connect an external white board to the Expansion Header.
With your guide , I able to solve Question 2 and 3. I just have doubt on Question1. The Question 1 is stated below.
Using XPS , I know that the LED IP’s ucf pin LOC is generated automatically, as shown below.
Net fpga_0_LEDs_4Bit_GPIO_IO_pin<0> LOC=G5;
Net fpga_0_LEDs_4Bit_GPIO_IO_pin<0> IOSTANDARD = LVCMOS25;
Net fpga_0_LEDs_4Bit_GPIO_IO_pin<0> PULLUP;
Net fpga_0_LEDs_4Bit_GPIO_IO_pin<0> SLEW = SLOW;
Net fpga_0_LEDs_4Bit_GPIO_IO_pin<0> DRIVE = 2;
Net fpga_0_LEDs_4Bit_GPIO_IO_pin<0> TIG;
But if I want to use Expansion Header, I need to write by myself. I only know how to find LOC (in ug080.pdf) .
1)But where do I get the other details? Is it necessary for me to insert the other details?
Your Help is really being appreciated
11-11-2008 02:48 AM - edited 11-11-2008 02:23 PM
Hi,
If you look at ug080.pdf, about page 21 you will see the tables of pins. In the text above is details about the jumper settings.
If you have the jumper to 3.3V for that bank, then your IO standard would be LVCMOS33 or LVTTL, if the jumper is set to 2.5V then your IO standard needs to be LVCMOS25.
If you want a weak pullup, then use the PULLUP directive. You can read up about the drive strength and slew rate control, but really you won't need these options if you are driving a LED through a buffer, except in the case when you have a LED directly connected to the FPGA then you may want to set the drive strength to maximum, but thats poor design anyhow.
Hope this helps.
Lachlan.
11-11-2008 07:53 PM
When I used BSB wizard, I set clock frequency to 100 MHz (Xilinx ML401, Microblaze). But how can I write a code to make the clock divide to 1 Hz? Instead of writing code, is there any other alternative way?
Thank you. Please keep it simple as I am not from engineer background and I am very new to FPGA world.
11-11-2008 07:55 PM
Thanks for replying. I really appreciated your answer because it was very simple and understandable. I am currently doing a traffic light project. Therefore my supervisor asked me to set a clock divide (in the attachment), to display the traffic light red to green transition in a slower motion.
When I used BSB wizard, I set clock frequency to 100 MHz (Xilinx ML401, Microblaze). But how can I write a code to make the clock divide to 1 Hz? Instead of writing code, is there any other alternative way?
Thank you. Please keep it simple as I am not from engineer background and I am very new to FPGA world.
11-11-2008 10:17 PM
Hi,
You should try and add a FIT timer to XPS this will generate an interrupt at fixed intervals.
Check out XPS FIT Timer, Its very easy to get going.
You will receive an interrupt every 1 second if you need. In software you can use the interrupt to increment your state machine.
Please let me know if you are doing it in VHDL rather than 'C' and i'll give you a VHDL clock example.
Regards
Lachlan.
11-11-2008 11:29 PM
Good morning
Hey thanks for your mail.
I really appreciate your help.
In the XPS9.2, there is FIXED INTERVAL TIMER (FIT) IP. After adding it , I can not get the API document.When I expand the IP in the PORTS tab, I find there INTERRUPT , RST and CLK.
1) How should I go about? What is the steps that I should take? Should I make it NEW CONNECTION or MAKE EXTERNAL?
In the attachment, the process A was interrupted by process B when time was 6. Let assume the time range is 1 to 10. After 10 it will return back to 1. It can be called as cycle. When process B completes and return to process A, the time is only 2. it needs to wait until the time is 6. Then only it can continue the process. This is called as calibration.
My idea was to implement for loop in the coding.
2) But if I want to use FIT, how can I write the code?
3) How TIMER, RST , CLK function should I use?
4) Can you send your VHDL sample code? I am doing in C program, can it be converted to C program? If can not, can you guide me with a simple C code?
Please keep it simple as I am new to FPGA world.
Thank you
11-12-2008 12:18 AM
Hi,
Compile and re-generate libraries and bsp's
You need to start your interrupt controller in your project. We do it very differently here because we build safety devices, however you can use the Xilinx supplied code.
Basically:
s16Return = XIntc_Initialize(&InterruptController, XPAR_INTC_0_DEVICE_ID);
s16Return = XIntc_Start(&InterruptController, XIN_REAL_MODE);
//connect to your controller. Replace NPU_UART.. with your FIT Timer
//Replace the callback Rx_Interrupt to your own.
s16Return = XIntc_Connect(&InterruptController, XPAR_XPS_INTC_0_NPU_UART_INTERRUPT_INTR, (XInterruptHandler)vCANNet_NetworkUART_Rx_Interrupt, (void*)0);
//Enable
XIntc_Enable(&InterruptController, XPAR_XPS_INTC_0_NPU_UART_INTERRUPT_INTR);
The function you passed into the callback should be called every time period.
You can test by inserting a breakpoint or toggling a led.
Regards
Lachlan.
11-12-2008 12:27 AM
Good morning
Thank you for your help, really appreciate it. Let me try on the normal GPIO LED first. If got any problem, I will contact you back.
Thank you sir
11-16-2008 06:50 PM
Good morning,
How can I convert a VHDL code into an EDK IP? What are the steps should I take?
Please explain in simple way as I am new to FPGA ?
Thank you
11-17-2008 12:07 AM
Good morning sir
I am using ISE 9.2 and EDK 9.2. I have done some VHDL codes , which runs perfectly in ISE and I able to download it. Now I want to convert all of them to an IP in XPS.
1)But how should I able to convert it ?
2)How am I going to define the input and output of the IP
2)What are the simple steps I need to do ?
I want to use the IP together with XPS UART to create a system. Please explain in a easy way because I am very new to FPGA world.
Thanks
11-17-2008 12:13 AM
Good morning sir
I am using ISE 9.2 and EDK 9.2. I have done some VHDL codes , which runs perfectly in ISE and I able to download it. Now I want to convert all of them to an IP in XPS.
1)But how should I able to convert it ?
2)How am I going to define the input and output of the IP
2)What are the simple steps I need to do ?
I want to use the IP together with XPS UART to create a system. Please explain in a easy way because I am very new to FPGA world.
Thanks
11-17-2008 03:11 AM
Good morning sir
I am using ISE 9.2 and EDK 9.2. I have done some VHDL codes , which runs perfectly in ISE and I able to download it. In the attachment, I had stated clearly my problem. Please go through it.
Now I want to convert all of them to an IP in XPS.
1)But how should I able to convert it ?
2)How am I going to define the input and output of the IP
2)What are the simple steps I need to do ?
I want to use the IP together with XPS UART to create a system. Please explain in a easy way because I am very new to FPGA world.
Thanks
11-18-2008 08:23 AM
moraali wrote:Good morning sir
I am using ISE 9.2 and EDK 9.2. I have done some VHDL codes , which runs perfectly in ISE and I able to download it. Now I want to convert all of them to an IP in XPS.
1)But how should I able to convert it ?
2)How am I going to define the input and output of the IP
2)What are the simple steps I need to do ?
I want to use the IP together with XPS UART to create a system. Please explain in a easy way because I am very new to FPGA world.
Thanks
The problem with your questions is that you are asking for simple steps to accomplish something that is somewhat complex.
And the way I create IP cores deviates from the Xilinx recommendations, so my answers might not be helpful.
Having said that: I suggest that you start with the EDK Tutorials.
Good luck,
-a
12-04-2008 03:57 PM
I unable to receive hyperterminal input. Based on the coding below I can send , but can not receive the information . How can I rectify this problem?
#include "xparameters.h"
#include "xuartlite.h"
#define UART_BASEADDR XPAR_UARTLITE_0_BASEADDR
#define ESCAPE 0x1b
static void myprintf (char *s)
{
while (*s)
{
XUartLite_SendByte (UART_BASEADDR ,*s );
s++;
}
}
void echo()
{
char s;
do
{
s = XUartLite_RecvByte(UART_BASEADDR); // Does s receive the string?
if (s == '\r')
{
XUartLite_SendByte (UART_BASEADDR , '\n' ); //It should send back to Hyperterminal, but no output
}
XUartLite_SendByte (UART_BASEADDR , s ); //It should send back to Hyperterminal, but no output
} while (s != ESCAPE);
}
int main()
{
myprintf("Good morning \r\n"); //OK, hyperterminal will display "Good morning"
echo(); //NOT OK, hyperterminal will not display "Good morning"
return 0;
}
12-04-2008 08:24 PM
Good morning sir,
Based on the coding below, when I pressed the push button, output appeared in the hyperterminal but does not light up the LED. What should I do to rectify this problem, in such when I push the button , the partucilar LED should Light up ?
#include "xparameters.h"
#include "xgpio.h"
#include "xutil.h"
int main (void)
{
XGpio led,Push;
int push_check1, push_check=0;
xil_printf("-- Entering main() --\r\n");
XGpio_Initialize(&led,XPAR_LEDS_4BIT_DEVICE_ID);
XGpio_Initialize(&Push,XPAR_PUSH_BUTTONS_5BIT_DEVICE_ID);
XGpio_SetDataDirection(&led,1,0x0);
XGpio_SetDataDirection(&Push,1,0xffffffff);
xil_printf("Press center push button to exit\r\n");
xil_printf("Any other to see corresponding LED turn ON\r\n");
push_check = XGpio_DiscreteRead(&Push,1);
while(1)
{
push_check1 = XGpio_DiscreteRead(&Push,1);
if(push_check1 != push_check)
{
push_check=push_check1;
if(push_check)
xil_printf("Push buttons status %0x\r\n", push_check1);
}
if(push_check==0x10)
{
break;
}
XGpio_DiscreteWrite(&led,1,push_check); // Should light up the LED. But it does not.
}
xil_printf("-- Exiting main() --\r\n");
return 0;
}