Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright (c) 2009 Xilinx, Inc. All rights reserved.
- *
- * Xilinx, Inc.
- * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
- * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
- * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR
- * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
- * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE
- * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
- * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
- * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO
- * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
- * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- */
- /*
- * helloworld.c: simple test application
- */
- #include "xbasic_types.h"
- #include "xstatus.h"
- #include "xparameters.h"
- #include "xtmrctr.h"
- #include "xtmrctr_i.h"
- #include <stdio.h>
- #include "xintc.h"
- #include "xintc_l.h"
- #include "platform.h"
- #include "mb_interface.h"
- int count = 0;
- int flag = 0;
- XTmrCtr XPS_Timer;
- XIntc XPS_Intc;
- void timer_handler(void * baseaddr){
- count++;
- flag = 1;
- }
- int main()
- {
- int x, y;
- //initialize components
- init_platform();
- xil_printf("Hello World\n\r");
- microblaze_enable_interrupts();
- microblaze_register_handler((XInterruptHandler) XIntc_DeviceInterruptHandler, NULL);
- XTmrCtr_Initialize(&XPS_Timer, XPAR_XPS_TIMER_0_DEVICE_ID);
- XTmrCtr_SetOptions(&XPS_Timer, XPAR_XPS_TIMER_0_DEVICE_ID, XTC_DOWN_COUNT_OPTION|XTC_INT_MODE_OPTION|XTC_AUTO_RELOAD_OPTION);
- XTmrCtr_SetHandler(&XPS_Timer, (XTmrCtr_Handler) timer_handler, NULL);
- XIntc_Initialize(&XPS_Intc, XPAR_XPS_INTC_0_DEVICE_ID);
- XIntc_Connect(&XPS_Intc, XPAR_XPS_INTC_0_XPS_TIMER_0_INTERRUPT_INTR, (XInterruptHandler) XTmrCtr_InterruptHandler, &XPS_Timer);
- XIntc_Start(&XPS_Intc, XIN_REAL_MODE);
- XIntc_Enable(&XPS_Intc, XPAR_XPS_TIMER_0_DEVICE_ID);
- XTmrCtr_SetResetValue(&XPS_Timer, XPAR_XPS_TIMER_0_DEVICE_ID, 0x02FAF080);
- // count = XTmrCtr_GetValue(&XPS_Timer, XPAR_XPS_TIMER_0_DEVICE_ID);
- // xil_printf("count start = %d\n\r", count);
- XTmrCtr_Start(&XPS_Timer, 0);
- // for(x=0; x<100; x++){
- // count = XTmrCtr_GetValue(&XPS_Timer, 0);
- // //xil_printf("count = %d\n\n\r", count);
- // for(y=0; y<1000000; y++);
- // }
- while(1){
- if(flag == 1){
- if(count == 10){
- xil_printf("\n\r");
- count = 0;
- }
- else{
- xil_printf(".");
- }
- flag = 0;
- }
- }
- //Disable
- //XTmrCtr_Stop(&XPS_Timer, 0);
- //XIntc_Stop(&XPS_Intc);
- //microblaze_disable_interrupts();
- cleanup_platform();
- return 0;
- }
Add Comment
Please, Sign In to add comment