开发板环境:vivado2017.4
开发板:Zedboard 芯片型号:xc7z020clg484-1
在zynq中分为MIO和EMIO,MIO是arm端的管脚,而EMIO是将arm端的管脚使用fpga管脚来进行扩展,本章主要使用MIO来点亮LED灯
从上图中可以看到MIO0~MIO53一共54个管脚,EMIO0~EMIO63一共64个管脚,下面开始新建工程,新建一共mio_led工程(如果不会新建请参考hello_world这章)
新建工程后,调用zynq核
导入配置文件mio.tcl
配置后可以看到GPIO项里面有MIO7(使用这个管脚点亮PS端的led)
生成综合文件
生成顶层文件
生成bit文件
生成bit文件成功
导出硬件配置
File-->Launch SDK打开SDK
点击New-->application Project新建fsbl
新建fsbl,点击Next
选择Zynq FSBL,点击Finish
新建的fsbl
再次点击New-->application Project,新建一个hello_world工程
新建hello_world工程,点击Next
选择Hello World工程模板,点击Finish
新建的hello_world工程
硬件连接
MIO代码
/******************************************************************************
*
* Copyright (C) 2009 - 2014 Xilinx, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* Use of the Software is limited solely to applications:
* (a) running on a Xilinx device, or
* (b) that interact with a Xilinx device through a bus or interconnect.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* XILINX BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* Except as contained in this notice, the name of the Xilinx shall not be used
* in advertising or otherwise to promote the sale, use or other dealings in
* this Software without prior written authorization from Xilinx.
*
******************************************************************************/
/*
* helloworld.c: simple test application
*
* This application configures UART 16550 to baud rate 9600.
* PS7 UART (Zynq) is not initialized by this application, since
* bootrom/bsp configures it to baud rate 115200
*
* ------------------------------------------------
* | UART TYPE BAUD RATE |
* ------------------------------------------------
* uartns550 9600
* uartlite Configurable only in HW design
* ps7_uart 115200 (configured by bootrom/bsp)
*/
#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xil_io.h"
#include "sleep.h"
#define Base_Address 0xE000A000
#define DIRM_0 0x00000204 //mio0~mio31
#define OEN_0 0x00000208 //mio0~mio31
#define MASK_DATA_0_LSW 0x00000000 //mio0~mio15 data
int main()
{
Xil_Out32(Base_Address + DIRM_0,0x00000080); //端口方向设置 (0为输入 1为输出)
Xil_Out32(Base_Address + OEN_0,0x00000080); //管脚使能
while(1)
{
Xil_Out32(Base_Address + MASK_DATA_0_LSW,0x00000080);
sleep(1);
Xil_Out32(Base_Address + MASK_DATA_0_LSW,0x00000000);
sleep(1);
}
}
使用SD卡启动,点亮MIO7(如果使用多个mio管脚,为了不干扰其它的管脚,最好先取值然后相或相应的位)
熄灭MIO7