zoukankan      html  css  js  c++  java
  • Xilinx ISE 12.3 LED测试程序

    1. 进入XPS,使用BSB wizard。

    2. 命名新建的工程,并选择I would like to creat a system for a custom board

    3. 板子参数:virtex4///xc4vsx25///ff668///-10

    4. 晶振频率100MHz,Local memory选16KB

    5. 点击Add Device,IO Interface Type选GPIO,Device选LEDS。GPIO Data Width就是板子上led的个数,选择6

    6. STDIN和STDOUT选NONE

    7. 点finish之后会弹出一个窗口,提示你需要该两个文件data/system.ucf和etc/download.cmd,点OK

    8. 在system下双击download.cmd文件。其中需要修改的是两处数字,这个数字表示的是你FPGA在JTAG链中是第几个。这里将1改为2.

    9. 在system下双击system.ucf文件,开始锁管脚。打开SEED-FEM025.pdf,找到clk、rst和LEDS的管脚,并修改。

    10. Hardware->Generate Netlist。这个过程比较费时。

    11. Software->Generate Libraries and BSPs

    12. 双击Application下sources下的TestApp_Memory.c,写程序。

    13. 在SEED-FEM025.pdf中可以看到赋值为1时led亮,LED的排列方式为:

    SEED

    led2

    led5

    led4

    led3

    led6

    led1

    14. 写完之后Software->Build All User Applications。

    无误之后就可以Download到板子上查看结果了 ,下面是源码:

    /*
     * Xilinx EDK 12.3 EDK_MS3.70d
     *
     * This file is a sample test application
     *
     * This application is intended to test and/or illustrate some 
     * functionality of your system.  The contents of this file may
     * vary depending on the IP in your system and may use existing
     * IP driver functions.  These drivers will be generated in your
     * XPS project when you run the "Generate Libraries" menu item
     * in XPS.
     *
     * Your XPS project directory is at:
     *    E:\Projects\FPGA\Xilinx\TEST12.3\light_led\
     */
    
    // Located in: microblaze_0/include/xparameters.h
    
    #include "xparameters.h"
    #include "xgpio.h"
    #include "xstatus.h"
    #define LED_DELAY 1000000
    XGpio LED_POINTER;
    //====================================================
    
    int main (void) {
       /*
        * Enable and initialize cache
        */
       #if XPAR_MICROBLAZE_0_USE_ICACHE
          Xil_ICacheInvalidate();
          Xil_ICacheEnable();
       #endif
    
       #if XPAR_MICROBLAZE_0_USE_DCACHE
          Xil_DCacheInvalidate();
           Xil_DCacheEnable();
       #endif
    
       #if XPAR_MICROBLAZE_0_USE_DCACHE
          Xil_DCacheDisable();
          Xil_DCacheInvalidate();
       #endif
    
       #if XPAR_MICROBLAZE_0_USE_ICACHE
          Xil_ICacheDisable();
          Xil_ICacheInvalidate();
       #endif
    
    volatile int DELAY;
    int count=0;
    
    XGpio_Initialize(&LED_POINTER,XPAR_LEDS_DEVICE_ID);
    XGpio_SetDataDirection(&LED_POINTER,1,0x0000);
    
    
    while(1)
     {count++;
     if(count%2==0)
      {
      XGpio_WriteReg(XPAR_LEDS_BASEADDR,1,0x02);
      }
     else
      {
      XGpio_WriteReg(XPAR_LEDS_BASEADDR,1,0x16);
      }
      
     for(DELAY=0;DELAY<LED_DELAY;DELAY++);
     
     if(count%2==0)
      {
      XGpio_WriteReg(XPAR_LEDS_BASEADDR,1,0x08);
      }
     else
      {
      XGpio_WriteReg(XPAR_LEDS_BASEADDR,1,0x04);
      }
      
      for(DELAY=0;DELAY<LED_DELAY;DELAY++);
      
      if(count%2==0)
      {
      XGpio_WriteReg(XPAR_LEDS_BASEADDR,1,0x32);
      }
     else
      {
      XGpio_WriteReg(XPAR_LEDS_BASEADDR,1,0x01);
      }
      
      for(DELAY=0;DELAY<LED_DELAY;DELAY++);
     }
     
       return 0;
    }
    
    
    
  • 相关阅读:
    如何突破单库性能瓶颈?
    高性能数据库表该如何设计?
    高性能索引该如何设计?(下)
    高性能索引该如何设计?(上)
    MySQL体系结构与存储引擎
    动态ViewPager导航页面
    ViewPager图片轮转带点的
    手动图片横向轮播
    安卓布局中下拉列表框的实现
    安卓中adapter的应用
  • 原文地址:https://www.cnblogs.com/shengansong/p/2014128.html
Copyright © 2011-2022 走看看