Guest User

Untitled

a guest
Jan 4th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. /*
  2. * Copyright (c) 2009 Xilinx, Inc. All rights reserved.
  3. *
  4. * Xilinx, Inc.
  5. * XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
  6. * COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
  7. * ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR
  8. * STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
  9. * IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE
  10. * FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
  11. * XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
  12. * THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO
  13. * ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE
  14. * FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY
  15. * AND FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. */
  18.  
  19. /*
  20. * helloworld.c: simple test application
  21. */
  22.  
  23. #include "xbasic_types.h"
  24. #include "xstatus.h"
  25. #include "xparameters.h"
  26. #include "xtmrctr.h"
  27. #include "xtmrctr_i.h"
  28. #include <stdio.h>
  29. #include "xintc.h"
  30. #include "xintc_l.h"
  31. #include "platform.h"
  32. #include "mb_interface.h"
  33.  
  34. int count = 0;
  35. int flag = 0;
  36. XTmrCtr XPS_Timer;
  37. XIntc XPS_Intc;
  38.  
  39. void timer_handler(void * baseaddr){
  40. count++;
  41. flag = 1;
  42. }
  43.  
  44. int main()
  45. {
  46. int x, y;
  47.  
  48. //initialize components
  49. init_platform();
  50. xil_printf("Hello World\n\r");
  51.  
  52. microblaze_enable_interrupts();
  53. microblaze_register_handler((XInterruptHandler) XIntc_DeviceInterruptHandler, NULL);
  54.  
  55. XTmrCtr_Initialize(&XPS_Timer, XPAR_XPS_TIMER_0_DEVICE_ID);
  56.  
  57. XTmrCtr_SetOptions(&XPS_Timer, XPAR_XPS_TIMER_0_DEVICE_ID, XTC_DOWN_COUNT_OPTION|XTC_INT_MODE_OPTION|XTC_AUTO_RELOAD_OPTION);
  58. XTmrCtr_SetHandler(&XPS_Timer, (XTmrCtr_Handler) timer_handler, NULL);
  59.  
  60. XIntc_Initialize(&XPS_Intc, XPAR_XPS_INTC_0_DEVICE_ID);
  61. XIntc_Connect(&XPS_Intc, XPAR_XPS_INTC_0_XPS_TIMER_0_INTERRUPT_INTR, (XInterruptHandler) XTmrCtr_InterruptHandler, &XPS_Timer);
  62.  
  63. XIntc_Start(&XPS_Intc, XIN_REAL_MODE);
  64. XIntc_Enable(&XPS_Intc, XPAR_XPS_TIMER_0_DEVICE_ID);
  65.  
  66. XTmrCtr_SetResetValue(&XPS_Timer, XPAR_XPS_TIMER_0_DEVICE_ID, 0x02FAF080);
  67. // count = XTmrCtr_GetValue(&XPS_Timer, XPAR_XPS_TIMER_0_DEVICE_ID);
  68. // xil_printf("count start = %d\n\r", count);
  69. XTmrCtr_Start(&XPS_Timer, 0);
  70.  
  71. // for(x=0; x<100; x++){
  72. // count = XTmrCtr_GetValue(&XPS_Timer, 0);
  73. // //xil_printf("count = %d\n\n\r", count);
  74. // for(y=0; y<1000000; y++);
  75. // }
  76.  
  77. while(1){
  78. if(flag == 1){
  79. if(count == 10){
  80. xil_printf("\n\r");
  81. count = 0;
  82. }
  83. else{
  84. xil_printf(".");
  85. }
  86. flag = 0;
  87. }
  88. }
  89.  
  90. //Disable
  91. //XTmrCtr_Stop(&XPS_Timer, 0);
  92. //XIntc_Stop(&XPS_Intc);
  93. //microblaze_disable_interrupts();
  94.  
  95. cleanup_platform();
  96.  
  97. return 0;
  98. }
Add Comment
Please, Sign In to add comment