cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor
Visitor
2,788 Views
Registered: ‎12-05-2008

Simple Doubt On GPIO Function?

Hi engineers,

 

 For your info, I am using:-

1) FPGA V4(ML401)

2) ISE 9.2

3) EDK9.2

 

I am currently doing a project where the user will press a button and this will send the data to the hyperterminal. Later the system will receive the data and trigger the LED. Below is a simple diagram.

For example,

If press GPIO_North , LED_North  will trigger

If press GPIO_South , LED_South  will trigger

 

 

PUSH_BUTTON (GPIO_NORT)  ==> UART(Send) ==> HYPERTERMINAL (0x1) ====> UART(Receive) ==> LED(LED_North)

PUSH_BUTTON (GPIO_NORT)  ==> UART(Send) ==> HYPERTERMINAL (0x2) ====> UART(Receive) ==> LED(LED_South)

 

 

After reading EDK API , I understand how abit about the code.Below is what I know (coreect me if I am wrong)

 

1) For LEDs

 

XGpio_Initialize(LED_instance, BASEADDRESS_DEVICE_ID);

XGpio_SetDataDirection (LED_instance, CHANNEL, DIRECTION);  //In direction is 0x1, Out direction is 0x0

XGpio_DiscreteWrite (LED_instance,CHANNEL , LED);

/*

 LED = 0x1 , trigger first LED pin in UCF

 LED = 0x2 , trigger second LED pin in UCF

 LED = 0x4 , trigger third LED pin in UCF

 LED = 0x8 , trigger fourth  LED pin in UCF

*/  

 

 

2) For Push-Buttons

 

 

XGpio_Initialize(Button_instance, BASEADDRESS_DEVICE_ID);

XGpio_SetDataDirection (Button_instance, CHANNEL, DIRECTION);  //In direction is 0x1 , Out direction is 0x0

XGpio_DiscreteRead (Button_instance,CHANNEL );

/*

    // Is this correct, or should I  insert PUSH_BUTTON

   XGpio_DiscreteRead (Button_instance,CHANNEL, PUSH_BUTTON );

*/

 

3) For UART

 

XUartLite_SendByte (UART_BASEADDR_ID , DATA ); //Send Data to Hyperterminal

XUartLite_RecvByte(UART_BASEADDR_ID);                //Receive Data from Hyperterminal

 

 

My problem :-

 

1) For DiscreteRead in Push-Button, how does the system knows which button I clicked or pressed? Is the code is wrong ? If wrong , how should I write?

 

2) I want to do a program.When I click a button, the particular LED must be triggered. I do not know how to combine the LED with the PUSH-BUTTON. How should I write the code?

 

3) For UART, how can I write a code to receive a string from the hyperterminal?

 

Is there any reference that I can study?

 

TQ

0 Kudos