{"id":7510,"date":"2024-10-05T00:56:09","date_gmt":"2024-10-04T16:56:09","guid":{"rendered":"http:\/\/www.hellofpga.com\/?p=7510"},"modified":"2024-10-08T12:36:15","modified_gmt":"2024-10-08T04:36:15","slug":"lemon_zynq_timer","status":"publish","type":"post","link":"http:\/\/www.hellofpga.com\/index.php\/2024\/10\/05\/lemon_zynq_timer\/","title":{"rendered":"\u57fa\u4e8eLemon ZYNQ\u7684PS\u5b9e\u9a8c\u4e94 \u5b9a\u65f6\u5668\u4e2d\u65ad\u5b9e\u9a8c"},"content":{"rendered":"\n<p>\u548c\u6240\u6709\u7684MCU\u4e00\u6837ZYNQ\u7684PS\u7aef\u4e5f\u6709\u81ea\u5df1\u7684\u5b9a\u65f6\u5668\u4e2d\u65ad\u529f\u80fd\uff0c\u672c\u8282\u5c06\u5bf9\u8be5\u529f\u80fd\u8fdb\u884c\u6f14\u793a\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6b64\u7ae0\u8282\u5185\u5bb9\u9002\u7528\u4e8eLemon ZYNQ\u4e3b\u677f\uff0c\u5982\u662f\u5176\u4ed6\u677f\u5b50\u8bf7\u770b\u5bf9\u5e94\u677f\u5b50\u76ee\u5f55<\/strong><\/li>\n\n\n\n<li><strong>\u672c\u6587\u5728 vivado2018.3\u7248\u672c\u4e0a\u6f14\u793a<\/strong><\/li>\n<\/ul>\n\n\n\n<p>\u5b9a\u65f6\u5668\u4e2d\u65ad\u53ef\u4ee5\u4e3a\u7cfb\u7edf\u63d0\u4f9b\u6807\u51c6\u7684\u65f6\u949f\uff0c\u5fc3\u8df3\uff0c\u4e5f\u53ef\u4ee5\u7528\u6765\u4f5c\u4e3a\u4e3a\u4e00\u4e9b\u8ba1\u7b97\u7684\u65f6\u95f4\u57fa\u51c6\uff08\u5982\u8109\u51b2\u5bbd\u5ea6\uff0c\u8109\u51b2\u5468\u671f\u7b49\uff09\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u90fd\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u3002<\/p>\n\n\n\n<p>ZYNQ\u4e2d\u6bcf\u4e2aARM core\u90fd\u6709\u81ea\u5df1\u7684\u79c1\u6709\u5b9a\u65f6\u5668\uff0c\u79c1\u6709\u5b9a\u65f6\u5668\u7684\u5de5\u4f5c\u9891\u7387\u4e3aCPU\u7684\u4e00\u534a\uff0c\u5982ZYNQ\u7684\u5de5\u4f5c\u9891\u7387\u4e3a666MHZ,\u5219\u5b9a\u65f6\u5668\u7684\u9891\u7387\u4e3a333MHz\uff0c\u540e\u9762\u9700\u8981\u6ce8\u610f\u8fd9\u4e2a\u65f6\u949f\u3002<\/p>\n\n\n\n<p>\u672c\u8282\u5185\u5bb9\u6211\u4eec\u5c06\u5b8c\u6210\u5b9a\u65f6\u5668\u4e2d\u65ad\u5b9e\u9a8c\uff0c\u5e76\u4e86\u89e3PS \u7aef\u79c1\u6709\u5b9a\u65f6\u5668\u7684\u4f7f\u7528\u65b9\u6cd5\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e00\u3001\u5b9e\u9a8c\u5185\u5bb9\uff1a<\/strong><\/h2>\n\n\n\n<p>\u6211\u4eec\u5728PS\u7aef\u8bbe\u7f6e\u4e00\u4e2a\u5b9a\u65f6\u5668\uff0c\u5e76\u8ba9\u5b9a\u65f6\u5668\u6bcf\u8ba1\u6570\u6ee11ms\u89e6\u53d1\u4e00\u6b21\u4e2d\u65ad\uff0c\u5e76\u4e14\u6bcf\u7d2f\u8ba1\u4e00\u79d2\u949f\u7684\u65f6\u5019\u70b9\u4eae\u6216\u8005\u7184\u706d\u4e00\u4e2aLED\u706f\uff0c\u6765\u8fbe\u5230\u6f14\u793a\u7684\u6548\u679c\u3002<\/p>\n\n\n\n<p>\u6240\u4ee5\u6574\u4e2a\u7cfb\u7edf\u6211\u4eec\u53ea\u9700\u8981\u5728BLOCK DESIGN \u4e2d zynq\u6838\u5185 \u62d3\u5c55\u4e00\u4e2aEMIO \u7684GPIO\u53e3\uff0c\u5e76\u7528PS\u7684SDK \u7a0b\u5e8f\u7684\u5b9a\u65f6\u5668\u6bcf\u79d2\u53bb\u9a71\u52a8\u8fd9\u4e2aGPIO\u5373\u53ef\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e8c\u3001\u5de5\u7a0b\u521b\u5efa<\/strong><\/h2>\n\n\n\n<p>\u5de5\u7a0b\u521b\u5efa\u7684\u8fc7\u7a0b\u53ef\u4ee5\u53c2\u8003\u8bd5\u9a8c\u4e00\u4e2d\u7684\u5185\u5bb9\uff0c\u8fd9\u91cc\u4e0d\u518d\u8be6\u7ec6\u63cf\u8ff0\u4e86\u3002<a href=\"http:\/\/www.hellofpga.com\/index.php\/2024\/10\/04\/lemon_zynq_ps_gpio_emio\/\">\u57fa\u4e8eLemon ZYNQ\u7684PS\u5b9e\u9a8c\u4e00 GPIO\u4e4b\u7528EMIO\u65b9\u5f0f\u70b9\u4eaeLED\uff08\u5b8c\u6574\u56fe\u6587\uff09<\/a>(\u82af\u7247\u578b\u53f7\u9009XC7Z020CLG400-1)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e09\u3001Vivado \u4e2d\u7684\u8bbe\u7f6e<\/strong><\/h2>\n\n\n\n<p>1\uff09\u5728BLOCK DESIGN \u4e2d\u641c\u7d22\u5e76\u6dfb\u52a0\u4e00\u4e2aZYNQ\u6a21\u5757<\/p>\n\n\n\n<p>2\uff09\u5728ZYNQ \u8bbe\u7f6e\u754c\u9762\uff0c\u8bbe\u7f6e DDR MT41K256M16RE-125\u7684\u578b\u53f7 \u548c\u4f4d\u5bbd16bit<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"768\" height=\"442\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-92.png\" alt=\"\" class=\"wp-image-2668\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-92.png 768w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2023\/01\/image-92-300x173.png 300w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>3\uff09\u56e0\u4e3aLemon ZYNQ\u4e3b\u677f\u7684PS\u65f6\u949f\u662f50M\u7684\u6676\u632f\u8f93\u5165\u7684\uff0c\u6240\u4ee5\u8fd9\u91cc\u9700\u8981\u628a\u9ed8\u8ba4\u7684PS\u8f93\u5165\u65f6\u949f33.33M\u6539\u621050M<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"531\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-22-1024x531.png\" alt=\"\" class=\"wp-image-7455\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-22-1024x531.png 1024w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-22-300x156.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-22-768x398.png 768w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-22.png 1060w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>4\uff09\u6dfb\u52a0\u4e00\u4e2aGPIO\u7684\u63a5\u53e3\uff08EMIO\u65b9\u5f0f\uff09\u4e3a\u540e\u9762\u70b9\u4eaeLED\u505a\u51c6\u5907<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"767\" height=\"364\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-14.png\" alt=\"\" class=\"wp-image-1486\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-14.png 767w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-14-300x142.png 300w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>5\uff09\u8bb0\u5f55\u4e0b CPU\u7684\u65f6\u949f\uff08\u8fd9\u91cc\u4e0d\u9700\u8981\u4fee\u6539 \u53ea\u9700\u8981\u770b\u4e00\u4e0b\u8bb0\u5f55\u4e0b\u5f53\u524d\u65f6\u949f\u9891\u7387\u5c31\u597d\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"935\" height=\"402\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-16.png\" alt=\"\" class=\"wp-image-1489\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-16.png 935w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-16-300x129.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-16-768x330.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>6\uff09\u5bf9GPIO make external\uff0c\u5e76\u4e14\u8fde\u63a5AXI\u7684\u65f6\u949f\uff08AXI\u9ed8\u8ba4\u5f00\u542f\u7684\uff0c\u8fd9\u91cc\u7528\u4e0d\u5230AXI\uff0c\u4e5f\u53ef\u4ee5\u53bb\u8bbe\u7f6e\u91cc\u5173\u95edAXI\u529f\u80fd\uff0c\u5c31\u4e0d\u9700\u8981\u8fde\u63a5\u4e86\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"606\" height=\"267\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-21.png\" alt=\"\" class=\"wp-image-1512\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-21.png 606w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-21-300x132.png 300w\" sizes=\"auto, (max-width: 606px) 100vw, 606px\" \/><\/figure>\n\n\n\n<p>7\uff09\u70b9\u9009Create HDL Wrapper<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"397\" height=\"165\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-22.png\" alt=\"\" class=\"wp-image-1513\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-22.png 397w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-22-300x125.png 300w\" sizes=\"auto, (max-width: 397px) 100vw, 397px\" \/><\/figure>\n\n\n\n<p>8\uff09\u4e4b\u540e\u521b\u5efa\u548c\u6dfb\u52a0\u7ea6\u675f\u6587\u4ef6\u5bf9\u7ba1\u811a\u8fdb\u884c\u5b9a\u4e49\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">set_property PACKAGE_PIN R14 [get_ports {GPIO_0_0_tri_io[0]}]<br>set_property IOSTANDARD LVCMOS33 [get_ports {GPIO_0_0_tri_io[0]}]<\/pre>\n\n\n\n<p>9) \u4e4b\u540e\u5bf9\u7a0b\u5e8f\u8fdb\u884c\u6b63\u5e38\u7684\u7f16\u8bd1\u7efc\u5408\uff0c\u5e76\u4e14\u5bfc\u51fa Export Hardware (\u52fe\u9009 include bitstream)\u4f9bSDK\u52a0\u8f7d<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"460\" height=\"92\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-24.png\" alt=\"\" class=\"wp-image-1515\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-24.png 460w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-24-300x60.png 300w\" sizes=\"auto, (max-width: 460px) 100vw, 460px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"318\" height=\"239\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-25.png\" alt=\"\" class=\"wp-image-1516\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-25.png 318w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-25-300x225.png 300w\" sizes=\"auto, (max-width: 318px) 100vw, 318px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u56db\u3001PS\u90e8\u5206\u7a0b\u5e8f\u8bbe\u8ba1\uff1a<\/strong><\/h2>\n\n\n\n<p>\u5728SDK\u73af\u5883\u4e0b\u5efa\u7acb\u4e00\u4e2aTIMER_TEST\u7a7a\u7684\u5de5\u7a0b\uff0c\u5e76\u4e14\u6dfb\u52a0main.c \u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#include \"xparameters.h\"\n#include \"xgpiops.h\"\n#include \"xstatus.h\"\n#include \"xplatform_info.h\"\n#include \"xscutimer.h\"\n#include \"Xscugic.h\"\n\n#define LED    \t54\n\n#define GPIO_DEVICE_ID  \tXPAR_XGPIOPS_0_DEVICE_ID\nXGpioPs Gpio;\n\n\nvoid Gpio_Init(void){\n\tXGpioPs_Config *ConfigPtr;\n\n\tConfigPtr = XGpioPs_LookupConfig(GPIO_DEVICE_ID);\n\tXGpioPs_CfgInitialize(&amp;Gpio, ConfigPtr,ConfigPtr-&gt;BaseAddr);\n\n\tXGpioPs_SetDirectionPin(&amp;Gpio, LED, 1);\n\tXGpioPs_SetOutputEnablePin(&amp;Gpio, LED, 1);\n\tXGpioPs_WritePin(&amp;Gpio, LED, 0);\n}\n\n\n#define TIMER_DEVICE_ID XPAR_XSCUTIMER_0_DEVICE_ID\n#define INTC_DEVICE_ID XPAR_SCUGIC_SINGLE_DEVICE_ID\n#define TIMER_IRPT_INTR XPAR_SCUTIMER_INTR\n#define TIMER_LOAD_VALUE 0x514c7 \/\/666*1000*1\/2 666mhz\nstatic XScuGic Intc; \/\/GIC\nstatic XScuTimer Timer;\/\/timer\n\nstatic void SetupInterruptSystem(XScuGic *GicInstancePtr,\nXScuTimer *TimerInstancePtr, u16 TimerIntrId);\nstatic void TimerIntrHandler(void *CallBackRef);\n\nvoid SetupInterruptSystem(XScuGic *GicInstancePtr,XScuTimer *TimerInstancePtr, u16 TimerIntrId){\n\tXScuGic_Config *IntcConfig; \/\/GIC config\n\tXil_ExceptionInit();\n\t\/\/initialise the GIC\n\tIntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);\n\tXScuGic_CfgInitialize(GicInstancePtr, IntcConfig,IntcConfig-&gt;CpuBaseAddress);\n\t\/\/connect to the hardware\n\tXil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,\n\t\t(Xil_ExceptionHandler)XScuGic_InterruptHandler,\n\t\tGicInstancePtr);\n\t\/\/set up the timer interrupt\n\tXScuGic_Connect(GicInstancePtr, TimerIntrId,\n\t\t(Xil_ExceptionHandler)TimerIntrHandler,\n\t\t(void *)TimerInstancePtr);\n\t\/\/enable the interrupt for the Timer at GIC\n\tXScuGic_Enable(GicInstancePtr, TimerIntrId);\n\t\/\/enable interrupt on the timer\n\tXScuTimer_EnableInterrupt(TimerInstancePtr);\n\t\/\/ Enable interrupts in the Processor.\n\tXil_ExceptionEnableMask(XIL_EXCEPTION_IRQ);\n}\n\nvolatile int ms_count;\nunsigned char led_state=0;\n\nstatic void TimerIntrHandler(void *CallBackRef){\n\tstatic int ms_count = 0; \/\/\u8ba1\u6570\n\tXScuTimer *TimerInstancePtr = (XScuTimer *) CallBackRef;\n\tXScuTimer_ClearInterruptStatus(TimerInstancePtr);\n\n\tms_count++;\n\tif(ms_count&gt;=1000){\n\t\tms_count=0;\n\t\tif(led_state==0)led_state=1;\n\t\telse led_state=0;\n\t\tXGpioPs_WritePin(&amp;Gpio, LED, led_state);\n\t}\n}\n\n\nvoid Timer_Init(){\n\tXScuTimer_Config *TMRConfigPtr;\n\tTMRConfigPtr = XScuTimer_LookupConfig(TIMER_DEVICE_ID);\n\tXScuTimer_CfgInitialize(&amp;Timer, TMRConfigPtr,TMRConfigPtr-&gt;BaseAddr);\n\tXScuTimer_SelfTest(&amp;Timer);\n\tXScuTimer_LoadTimer(&amp;Timer, TIMER_LOAD_VALUE);\n\t\/\/\u81ea\u52a8\u88c5\u8f7d\n\tXScuTimer_EnableAutoReload(&amp;Timer);\n\t\/\/\u542f\u52a8\u5b9a\u65f6\u5668\n\tXScuTimer_Start(&amp;Timer);\n\t\/\/set up the interrupts\n\tSetupInterruptSystem(&amp;Intc,&amp;Timer,TIMER_IRPT_INTR);\n}\nint main(void)\n{\n\tGpio_Init();\n\tTimer_Init();\n\n\twhile(1);\n\n\treturn 0;\n}\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e94\u3001\u4ee3\u7801\u7b80\u5355\u4ecb\u7ecd <\/strong><\/h2>\n\n\n\n<p>Timer_Init(); \u662f\u5b9a\u65f6\u5668\u7684\u521d\u59cb\u5316\u51fd\u6570\uff0c\u5728\u7cfb\u7edf\u8fd0\u884c\u7684\u65f6\u5019\uff0c\u9700\u8981\u5bf9\u5b9a\u65f6\u5668\u521d\u59cb\u5316\u624d\u80fd\u6b63\u5e38\u5de5\u4f5c\uff0c\u5176\u4e2dTIMER_LOAD_VALUE \u7528\u6765\u63a7\u5236 \u6bcf\u4e00\u6b21\u5b9a\u65f6\u5668\u89e6\u53d1\u7684\u65f6\u95f4\uff0c \u8fd8\u8bb0\u5f97\u6211\u4eec\u524d\u9762\u7684CPU\u65f6\u949f\u4e3a666mhz\u5417\uff0c\u90a3\u6211\u4eec\u7684\u5b9a\u65f6\u5668\u65f6\u949f\u5c31\u76f8\u5f53\u4e8e\u5de5\u4f5c\u57281\/2\u7684CPU\u65f6\u949f\u5373333mhz\u9891\u7387\u4e0b\u3002 \u6211\u4eec\u7684\u7cfb\u7edf\u8bbe\u7f6e\u662f\u6bcf1ms\u8fdb\u5165\u4e00\u6b21\u4e2d\u65ad\uff0c\u90a31ms\u5c31\u76f8\u5f53\u4e8e\u9700\u8981\u8ba1\u6570\uff08333000000\uff09*1\/1000=333000\u4e2a\u5468\u671f\uff0c\u90a3\u6211\u4eec\u5c31\u8bbe\u7f6eTIMER_LOAD_VALUE \u4e3a 333000-1\uff0c\u53730x514c7 (\u8fd9\u91cc\u4ee3\u88681ms\u7684\u6570\u503c\uff09<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"188\" height=\"177\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/11\/image-18.png\" alt=\"\" class=\"wp-image-1495\"\/><\/figure>\n\n\n\n<p>TimerIntrHandler \u662f\u5b9a\u65f6\u5668\u7684\u56de\u8c03\u51fd\u6570\uff0c\u76f8\u5f53\u4e8e\u5355\u7247\u673a\u7684\u4e2d\u65ad\u670d\u52a1\u51fd\u6570\uff0c\u6bcf\u5f53\u4e2d\u65ad\u88ab\u89e6\u53d1\uff0c\u5c31\u4f1a\u8c03\u7528\u4e00\u6b21\u8be5\u56de\u8c03\u51fd\u6570\u3002 \u56e0\u4e3a\u662f1ms\u8fdb\u5165\u4e00\u6b21\uff0c\u6240\u4ee5\u5047\u8bbe\u6211\u4eec\u9700\u8981\u8ba1\u65701S\u949f\uff0c\u5c31\u9700\u8981\u989d\u5916\u589e\u52a0\u4e00\u4e2a\u53d8\u91cfms_count<\/p>\n\n\n\n<p>\u6bcf\u6b21\u8fdb\u5165\u8be5\u56de\u8c03\u51fd\u6570 ms_count\u90fd\u81ea\u589e\uff0c\u5f53\u5927\u4e8e\u7b49\u4e8e1000\u7684\u65f6\u5019\u8ba9ms_count\u5f52\u96f6\u5b8c\u6210\u4e00\u6b21\u5faa\u73af\uff0c\u540c\u65f6\u6267\u884c\u6211\u4eec\u7684LED\u53d8\u6362\u64cd\u4f5c\u3002 \u5982\u679c\u6211\u4eec\u6709\u5176\u4ed6\u7a0b\u5e8f\u9700\u8981\u6dfb\u52a0\uff0c\u4e5f\u53ef\u4ee5\u589e\u52a0\u5230 TimerIntrHandler\u7684\u56de\u8c03\u51fd\u6570\u949f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ms_count++;\nif(ms_count&gt;=1000){\n    ms_count=0;\n\n    if(led_state==0)led_state=1;\n    else led_state=0;\n    XGpioPs_WritePin(&amp;Gpio, LED, led_state);\n}<\/pre>\n\n\n\n<p>\u5bf9\u4e8emain\u51fd\u6570\u6765\u8bf4\uff0c\u6211\u4eec\u53ea\u9700\u8981\u6267\u884cGPIO \u548c\u5b9a\u65f6\u5668\u7684\u521d\u59cb\u5316\u5c31\u597d<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">int main(void){\n\tGpio_Init();\n\tTimer_Init();\n\twhile(1);\n\treturn 0;\n}<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u4e94\u3001\u4e0b\u8f7d\u4e0e\u9a8c\u8bc1<\/strong><\/h2>\n\n\n\n<p>1\uff09\u65b0\u521b\u5efa\u7684\u5de5\u7a0b\u6700\u597d\u5148\u5bf9Run as \u8fdb\u884c\u914d\u7f6e\uff1a\u53f3\u952e\u5de5\u7a0b\uff0c\u5e76\u70b9\u9009Run As -&gt; Run Configurations<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"798\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-27.png\" alt=\"\" class=\"wp-image-7494\" style=\"width:626px;height:auto\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-27.png 750w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-27-282x300.png 282w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><\/figure>\n\n\n\n<p>2\uff09 \u5728\u5f39\u51fa\u7684\u7a97\u53e3\u4e2d\u5bf9Reset entire system \u548c Program FPGA\u4e24\u4e2a\u9009\u9879\u8fdb\u884c\u52fe\u9009\u64cd\u4f5c\uff0c\u8fd9\u6837\u5c31\u4e0d\u4f1a\u51fa\u73b0\u4e0b\u8f7d\u7a0b\u5e8fdebug\u7684\u65f6\u5019\u6982\u7387\u6027\u4e0d\u5de5\u4f5c\u7684\u95ee\u9898\u4e86\u3002<strong>\uff08\u8fd9\u6837\u64cd\u4f5c\u540e\u7cfb\u7edf\u4f1a\u81ea\u52a8\u5bf9FPGA\u8fdb\u884c\u914d\u7f6e\uff0c\u4e0d\u9700\u8981\u6309\u4e4b\u524d\u5de5\u7a0b\u624b\u52a8\u5bf9FPGA\u8fdb\u884c\u7f16\u7a0b\u4e86\uff09<\/strong><\/p>\n\n\n\n<p>PS\u5982\u679c\u6ca1\u6709\u51fa\u73b0\u4e0b\u56fe\u5bf9\u8bdd\u6846\uff0c\u53ef\u4ee5\u76f4\u63a5\u53cc\u51fb\u5de6\u4fa7\u7684applicationo \uff08System Debugger\uff09\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"705\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-29-1024x705.png\" alt=\"\" class=\"wp-image-7496\" style=\"width:629px;height:auto\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-29-1024x705.png 1024w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-29-300x206.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-29-768x528.png 768w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/image-29.png 1401w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p>3\uff09\u8bbe\u7f6e\u597d\u4e4b\u540e\uff0c\u9009\u62e9<code>Run As<\/code>&nbsp;-&gt;&nbsp;<code>Launch on Hardware (System Debugger)<\/code>&nbsp;\u8fdb\u884c\u8c03\u8bd5\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"178\" src=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/07\/image-14.png\" alt=\"\" class=\"wp-image-835\" style=\"width:631px;height:auto\" srcset=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/07\/image-14.png 780w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/07\/image-14-300x68.png 300w, http:\/\/www.hellofpga.com\/wp-content\/uploads\/2022\/07\/image-14-768x175.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>\u4e0b\u8f7d\u5230\u6211\u4eec\u7684\u677f\u5b50\u4e0a\uff0c\u53ef\u4ee5\u770b\u5230 \u4e3b\u677f\u4e0a\u7684LED \u706f\u6bcf\u79d2\u949f\u95ea\u70c1\u4e00\u6b21\uff0c \u8bf4\u660e\u6211\u4eec\u7684\u5b9a\u65f6\u5668\u7a0b\u5e8f\u6b63\u5e38\u5728\u5de5\u4f5c\u4e86\u3002\u7a0b\u5e8f\u6bd4\u8f83\u7b80\u5355\uff0c\u4ec5\u4f9b\u53c2\u8003\u5b66\u4e60\uff0c\u5bf9\u4e8eZYNQ\u7684\u5b9a\u65f6\u5668\u6765\u8bf4\uff0c\u8fd8\u6709\u5f88\u591a\u529f\u80fd\uff08\u5305\u62ec\u7528PL\u53bb\u89e6\u53d1\u5b9a\u65f6\u5668\u4e2d\u65ad\u7b49\uff09\uff0c\u9700\u8981\u5b9e\u9645\u505a\u9879\u76ee\u7684\u65f6\u5019\u81ea\u884c\u53bb\u62d3\u5c55\u4e86\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u672c\u6587\u7684\u5b8c\u6574\u5de5\u7a0b\u4e0b\u8f7d\uff1a<a href=\"http:\/\/www.hellofpga.com\/wp-content\/uploads\/2024\/10\/05_PS_TIMER_TEST.zip\">05_PS_TIMER_TEST<\/a><\/strong><\/li>\n\n\n\n<li><strong>VIVADO\u7684\u7248\u672c\uff1a2018.3<\/strong><\/li>\n\n\n\n<li><strong>\u5de5\u7a0b\u521b\u5efa\u76ee\u5f55\uff1a E:\\Lemon_ZYNQ\\SDK\\05_PS_TIMER_TEST<\/strong><\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u548c\u6240\u6709\u7684MCU\u4e00\u6837ZYNQ\u7684PS\u7aef\u4e5f\u6709\u81ea\u5df1\u7684\u5b9a\u65f6\u5668\u4e2d\u65ad\u529f\u80fd\uff0c\u672c\u8282\u5c06\u5bf9\u8be5\u529f\u80fd\u8fdb\u884c\u6f14\u793a\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22],"tags":[],"class_list":["post-7510","post","type-post","status-publish","format-standard","hentry","category-lemon-zynq"],"views":1106,"_links":{"self":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/7510","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/comments?post=7510"}],"version-history":[{"count":8,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/7510\/revisions"}],"predecessor-version":[{"id":7665,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/posts\/7510\/revisions\/7665"}],"wp:attachment":[{"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/media?parent=7510"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/categories?post=7510"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.hellofpga.com\/index.php\/wp-json\/wp\/v2\/tags?post=7510"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}