Nandhini.C
Newbie level 3
xil_printf
i can able to do only vry vry simple application as glowing led and reading key.
i can able to do only vry vry simple application as glowing led and reading key.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
muralicrl said:Hi,
Just see the attachment, which describes about EDK.
#include "stdio.h"
#include "xparameters.h"
#include "xgpio_l.h"
#include "xgpio.h"
#include "xstatus.h"
#include "xuartlite_l.h"
#include "xuartlite.h"
#define LED_DELAY 1000000
#define LED_ID XPAR_LEDS_DEVICE_ID
#define UART_ID XPAR_RS232_DEVICE_ID
XStatus UartLiteSelfTestExample(Xuint16 DeviceId);
XUartLite xUART;
int main(void)
{
XGpio gpLED;
XGpio gpPB;
XStatus Status;
int i,j,k;
volatile int Delay;
xil_printf("Welcome to the MicroBlaze Developement Kit.");
xil_printf("\n\t\t\t\t\t This is a test application for GPIO.");
xil_printf("\n\t\t\t\t\t\t This application blinks the LEDs alternatively.");
// Initialise the peripherals
XGpio_Initialize(&gpLED, LED_ID);//XPAR_LEDS_DEVICE_ID);
// Set the LED peripheral to outputs
XGpio_mSetDataDirection(&gpLED, 1, 0x00000000);
//XGpio_DiscreteSet(&gpLED, 1, data);
for (i = 0; i < 5; i++)
{
for(j = 0; j < 5; j++)
{
xil_printf("\n\t\t\t\t\t\t\t Inside FOR loop2.\t\t");
XGpio_DiscreteSet(&gpLED, 1, (int)0x000000AA);
for (Delay = 0; Delay < LED_DELAY; Delay++);
XGpio_DiscreteSet(&gpLED, 1, (int)0x000000FF);
for (Delay = 0; Delay < LED_DELAY; Delay++);
XGpio_DiscreteSet(&gpLED, 1, (int)0x00000055);
for (Delay = 0; Delay < LED_DELAY; Delay++);
XGpio_DiscreteSet(&gpLED, 1, (int)0x000000FF);
}
xil_printf("\n\t\t\t\t\t\t Inside FOR loop1.\t");
for (Delay = 0; Delay < LED_DELAY; Delay++);
}
xil_printf("\n\t\t\t\t\t\t\t\t Now performing UART Self-Test...");
/*
* Run the UartLite self test example, specify the the Device ID that is
* generated in xparameters.h
*/
Status = UartLiteSelfTestExample(XPAR_RS232_DEVICE_ID); //XPAR_RS232_DEVICE_ID);
xil_printf("\n\t\t\t\t\t\t\t\t Checking UART initialization status");
xil_printf("\n\t\t\t\t\t\t\t Status : %d",Status);
xil_printf("\n\t\t\t\t\t\t\t Status : %d",XST_SUCCESS);
xil_printf("\n\t\t\t\t\t\t\t\t\t UART Self-test Successful!");
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
xil_printf("\nUART Self-test Failed!");
}
return XST_SUCCESS;
}
// Function that performs a self-test on the UART
XStatus UartLiteSelfTestExample(Xuint16 DeviceId)
{
XStatus Status;
xil_printf("\n\t\t\t\t\t\t Entering UART Self-test function");
/*
* Initialize the UartLite driver so that it is ready to use.
*/
xil_printf("\n\t\t\t\t\t\t Initializing UART");
Status = XUartLite_Initialize(&xUART, DeviceId);
xil_printf("\n\t\t\t\t\t\t\t\t Initialized UART");
xil_printf("\n\t\t\t\t\t\t\t\t\t UART Device ID:%d", DeviceId);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
xil_printf("\nFailed to initialize UART!!!");
}
/*
* Perform a self-test to ensure that the hardware was built correctly.
*/
Status = XUartLite_SelfTest(&xUART);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
return XST_SUCCESS;
}
hellow sir /mamNandhini.C said:i can able to do only vry vry simple application as glowing led and reading key.
cj007 said:I have a completed version of EDK training material from Xilinx Training (USD1000/course).
1) Embedded System Design
2) Advanced Embedded System Design.
- Hardcopy + Training Lab.
The EDK training material (hardcopy)/course may cost you USD 10. If you need it, please feel free to contact me.
Thanks.
XStatus GpioOutputExample(Xuint16 DeviceId, Xuint32 GpioWidth)
{
Xuint32 Data;
volatile int Delay;
Xuint32 LedBit;
Xuint32 LedLoop;
XStatus Status;
/* Initialize the GPIO driver so that it's ready to use,
* specify the device ID that is generated in xparameters.h
*/
Status = XGpio_Initialize(&GpioOutput, DeviceId);
if (Status != XST_SUCCESS)
{
return XST_FAILURE;
}
/* Set the direction for all signals to be outputs
*/
XGpio_SetDataDirection(&GpioOutput, LED_CHANNEL, 0x0);
/* Set the GPIO outputs to low
*/
XGpio_DiscreteWrite(&GpioOutput, LED_CHANNEL, 0x0);
for (LedBit = 0x0; LedBit < GpioWidth; LedBit++)
{
for (LedLoop = 0; LedLoop < LED_MAX_BLINK; LedLoop++)
{
/* Set the GPIO Output to High
*/
XGpio_DiscreteWrite(&GpioOutput, LED_CHANNEL, 1 << LedBit);
#ifndef __SIM__
/*
* Wait a small amount of time so the LED is visible
*/
for (Delay = 0; Delay < LED_DELAY; Delay++);
#endif
/* Read the state of the data so that it can be verified
*/
/* Data = XGpio_DiscreteRead(&GpioOutput, LED_CHANNEL); */
/* If the data read back is not the same as the data
* written then return FAILURE
*/
/*if (Data != (1 << LedBit))
{
return XST_FAILURE;
}*/
/* Clear the GPIO Output
*/
XGpio_DiscreteClear(&GpioOutput, LED_CHANNEL, 1 << LedBit);
/* Read the state of the data so that it can be verified
*/
/* Data = XGpio_DiscreteRead(&GpioOutput, LED_CHANNEL);*/
/* If the data read back is not the same as the data
* written then return FAILURE
*/
/* if (Data & ( 1 << LedBit))
{
return XST_FAILURE;
}*/
#ifndef __SIM__
/*
* Wait a small amount of time so the LED is visible
*/
for (Delay = 0; Delay < LED_DELAY; Delay++);
#endif
}
}
return XST_SUCCESS;
}
LED coding in EDK is much easy. I can give that. But much of the hidden registers are unknown. For example to read a data from a port, you can use "mgetdatareg(DIP_SWITCH_base_address,2,1)....". There is another syntax "mread_data_reg". But I don't really know what is the difference between these two...The meaning for the syntax has not been described anywhere.I just had to learn it myself...That is the problem. You must know what are the syntax available for using the appropriate peripheral. I have only few sample coding which restricts my usage at all cost..Some expert could help us.rajisvec said:can anyone say,how to do simple examples such as glowing of LEDs in EDK.
please give the details and materials regarding to it.
cj007 said:I have a completed version of EDK training material from Xilinx Training (USD1000/course).
1) Embedded System Design
2) Advanced Embedded System Design.
- Hardcopy + Training Lab.
The EDK training material (hardcopy)/course may cost you USD 10. If you need it, please feel free to contact me.
Thanks.