ireon
Junior Member level 2
- Joined
- Mar 28, 2013
- Messages
- 21
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 1,283
- Activity points
- 1,455
MicroBlaze first program
I created my first program "Hello World" using MicroBlaze. I created hardware interface with MicroBlaze, UART, GPI and GPO. After hardware creation I programmed my FPGA Spartan 3E and on the terminal sreen is appeared the string "Hello World". Later I modified program as shown below:
So the string "Reading switches and writing to LED port" appears on the terminal screen and when I change switches position, the corrisponding LED lights.
Now I would create a source C file to read DIP switches state, therefore the state is visualized on the terminal screen. How could I do it?
I read that it's possible to use the xgpio.h library and function XGpio_SetDataDirection, XGpio_Initialize, XGpio_DiscreteRead and XGpio_DiscreteWrite, but when I create a new source c file including xgpio.h an error occurs: "no such file or directory". Why? Could someone help me?
I am using SDK by Xilinx.
I created my first program "Hello World" using MicroBlaze. I created hardware interface with MicroBlaze, UART, GPI and GPO. After hardware creation I programmed my FPGA Spartan 3E and on the terminal sreen is appeared the string "Hello World". Later I modified program as shown below:
Code:
#include <stdio.h>
#include "platform.h"
#include "xparameters.h" // add
#include "xiomodule.h" // add
void print(char *str);
int main()
{
init_platform();
u32 data;
XIOModule gpi;
XIOModule gpo;
print("Reading switches and writing to LED port");
data = XIOModule_Initialize(&gpi, XPAR_IOMODULE_0_DEVICE_ID);
data = XIOModule_Start(&gpi);
data = XIOModule_Initialize(&gpo, XPAR_IOMODULE_0_DEVICE_ID);
data = XIOModule_Start(&gpo);
while (1)
{
data = XIOModule_DiscreteRead(&gpi, 1); // read switches (channel 1)
XIOModule_DiscreteWrite(&gpo, 1, data); // turn on LEDs (channel 1)
}
cleanup_platform();
return 0;
}
So the string "Reading switches and writing to LED port" appears on the terminal screen and when I change switches position, the corrisponding LED lights.
Now I would create a source C file to read DIP switches state, therefore the state is visualized on the terminal screen. How could I do it?
I read that it's possible to use the xgpio.h library and function XGpio_SetDataDirection, XGpio_Initialize, XGpio_DiscreteRead and XGpio_DiscreteWrite, but when I create a new source c file including xgpio.h an error occurs: "no such file or directory". Why? Could someone help me?
I am using SDK by Xilinx.
Last edited by a moderator: