标题:
深入浅出FPGA-16-xilinx_zynq7000_EPP上一个简单实验(PS)
[打印本页]
作者:
pengpengpang
时间:
2014-9-19 11:18
标题:
深入浅出FPGA-16-xilinx_zynq7000_EPP上一个简单实验(PS)
现在的FPGA都很强大了,不仅有丰富的LE(LC),高端的还集成了CPUcore。这样,从硬件上就能做SOC,从软件上可以做嵌入式。本节就做一个简单的实验,主要熟悉这个板子的PS资源。15.1 实验目的1》 熟悉zynq7000 EPP资源和design suite2》 SDK编码,实现一个简单逻辑。15.2 实验环境Board :ZYNQ7000 EPPDevice:XC7Z020CLG484ACX1221Design suite:14.1 (PlanAhead+XPS+SDK)15.3 实验准备a) 会planAhead创建工程b) 简单了解和使用XPS和SDK15.4 实验内容a) 在XPS添加GPIO,此GPIO连到外部一个LED上。b) 在SDK编写C代码控制GPIO来控制此LED的闪烁。15.5 实验步骤a) 打开planAhead,创建embedded新工程,添加PS7。b) 打开XPS,添加GPIO。注意port名称,ucf文件里要用。c) 添加UCF文件,内容:simple_led.ucf。d) Create TOP HDL,然后生成bitstream。e) 导出hardware,launch SDK。f) 在SDK里创建helloword工程。g) SDK编码,内容:helloworld.c。h) Program FPGAi) Run AS,configurej) Run15.6 实验结果看板子,DS18这个led会闪烁。下图是串口打印信息:可以看到,可以通过软件来控制GPIO,就像在单片机上开发一样。
附:SDK 代码:[html]
view plain
copy
print
?
/*
* 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 <stdio.h>
#include "platform.h"
#include "../../hello_world_bsp_0/ps7_cortexa9_0/include/xgpio.h"
#include "../../hello_world_bsp_0/ps7_cortexa9_0/include/xparameters.h"
#define MY_GPIO_DEVICE_ID XPAR_AXI_GPIO_0_DEVICE_ID
void my_process(void);
void led_flash(XGpio* led_p,unsigned int time,int count);
void my_delay(int times);
int main()
{
init_platform();
my_process();
printf("my_process end!\r\n");
cleanup_platform();
return 0;
}
//==========================
void my_process(void)
{
XGpio led;
int ret = 0;
int read_led = 0;
printf("my_process start...\n");
ret = XGpio_Initialize(&led,MY_GPIO_DEVICE_ID);//led init
if(0 != ret)
{
printf("led init error:%d\n",ret);
}
else
{
printf("led init ok!%d \n\n",ret);
}
XGpio_SetDataDirection(&led,1,0x00000000);
printf("setdir: input!\n\n");
led_flash(&led,0xffffff,100);
#if 0
read_led = XGpio_DiscreteRead(&led,1);//init read
printf("before led read:%d\n\n",read_led);
XGpio_DiscreteWrite(&led,1,0);//write 0
printf("write 0!\n\n\n");
read_led = XGpio_DiscreteRead(&led,1);//read again
printf("led read:%d\n\n",read_led);
XGpio_DiscreteWrite(&led,1,1);//write 1
printf("write 1!\n\n\n");
read_led = XGpio_DiscreteRead(&led,1);//read again
printf("led read:%d\n\n",read_led);
#endif
return;
}
void my_delay(int times)
{
while(times--)
{
;//do nothing.
}
}
void led_flash(XGpio* led_p,unsigned int time,int count)
{
int loop = 0;
for(loop=0;loop<count;loop++)
{
XGpio_DiscreteWrite(led_p,1,1);//write 0
my_delay(time);
XGpio_DiscreteWrite(led_p,1,0);//write 0
my_delay(time);
}
}
来源:
rill_zhen的专栏
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/)
Powered by Discuz! 7.0.0