By Amirhossein Divanpour
[email protected]
Microblaze Making a new empty project: Instead of choosing helloworld in file >> new >> application project choose empty application.
Figure 1
Right click on project name and choose new >> file / source file File is like helloworld.c in the figure1 and source figure1.it’s so important to enter a name with .c suffix like amir.c. It’s a better way to click on source file.
file
is
like
amir.c
in
to open a option of creating header file or
In microblaze you build a hardware by one time of program FPGA and you can change your program and build it by program
line
by line
and
tools its so important to click on
check
variables
and run it by by
but
and test the
before
using
these
!!!!!
How to find a header file for my project? You should search your header D:\XILINX\14.7\ISE_DS\EDK\sw\XilinxProcessorIPLib\drivers
file
in
When you find it copy it and paste to src of your project in SDK. EX: xscutimer.h is in scutimer_v1_02_a so you scutimer_v1_02_a in src and then resolve all errors by deleting extra folders.
should
copy
By Amirhossein Divanpour
[email protected] EX: tmrctr_v2_05_a is used for taking time by xtmrctr.h . For using the Examples you can search D:\XILINX\14.7\ISE_DS\EDK\sw\XilinxProcessorIPLib\drivers(and with ie. DEV c++).
Taking exceuting time for a code : First of all choose the timer :
Figure 2
In XPS set the timer in mb_plb mode and set the UCF as follows.
Figure 3
Net fpga_0_RS232_RX_pin LOC=P14; Net fpga_0_RS232_TX_pin LOC=P12; Net fpga_0_clk_1_sys_clk_pin TNM_NET = sys_clk_pin; TIMESPEC TS_sys_clk_pin = PERIOD sys_clk_pin 48000 kHz; Net fpga_0_clk_1_sys_clk_pin LOC=P56; Net fpga_0_rst_1_sys_rst_pin TIG; Net fpga_0_rst_1_sys_rst_pin LOC=P17;
“example” open
in it
By Amirhossein Divanpour
[email protected] You can see that timer is added:
Figure 4
Use the following code in figure 5 :
Figure
Change the code in helloworld as follows: #include #include #include #include #include
"platform.h" "xtmrctr_l.h" "xtmrctr.h" "xparameters.h"
int main() { u32 t=0; u32 r=0; u32 D=0;
By Amirhossein Divanpour
[email protected] u32 ControlStatus=0; //XTmrCtr *(addr)=; // int Status; //if (Status != XST_SUCCESS) { // print("err"); //return XST_FAILURE; // } XTmrCtr_SetControlStatusReg(0x83c00000 ,0 ,0x0); XTmrCtr_SetLoadReg(0x83c00000 ,0 , 0xDEADBEEF); XTmrCtr_LoadTimerCounterReg(0x83c00000 ,0); t = XTmrCtr_GetTimerCounterReg(0x83c00000,0); XTmrCtr_SetControlStatusReg(0x83c00000 ,0 ,ControlStatus & (~XTC_CSR_LOAD_MASK)); XTmrCtr_Enable(0x83c00000, 0); print("Hello\n\r"); delay(); r = XTmrCtr_GetTimerCounterReg(0x83c00000,0); D=r-t; printf("\n%llu",D); XTmrCtr_Disable(0x83c00000, 0); return XST_SUCCESS; } void delay(void) { int x=0; int y=0; for (x=0;x