Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

MicroBlaze first programm

Status
Not open for further replies.

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:


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:

Re: 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.

XGPIO reffer to external GPIO periferials you are not using, hance you don't have the gpio.h in your BSP.
the latest microblaze added GPI, GPO to the mb core.
 

So I should add external GPIO when I create MicroBlaze IP Core?
 

So I should add external GPIO when I create MicroBlaze IP Core?

basically you don't need to,

as you stated the XIOModule GPI , and GPO are working fine, so why do you want to change them ?
XIOModule is lighter and faster then any other external peripheral.

if you are using the mb MCS, then XIOModule is your only option.
 

So I could write the program to read leds state using XIOModule functions and xil_printf?
 

So I could write the program to read leds state using XIOModule functions and xil_printf?

yes of course you can.

you can also use :

XIOModule_Send (inst,data, count)

outbyte(char) to write to your uart.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top