S03_CH02_AXI_DMA PL发送数据到PS

S03_CH02_AXI_DMA PL发送数据到PS

1.1概述

本课程的设计原理分析。

本课程循序渐进,承接《S03_CH01_AXI_DMA_LOOP 环路测试》这一课程,在DATA FIFO端加入FPGA代码,通过verilog 代码对FIFO写。其他硬件构架和《S03_CH01_AXI_DMA_LOOP 环路测试》一样。

《S03_CH01_AXI_DMA_LOOP 环路测试》课程中,详解讲解了工程步骤的创建,本章开始,一些简单的操作步骤将会省去。

1.2系统构架框图

wpsB595.tmp

在上图中,红色标记部分是和前面课程有稍微差异的部分。读者需要好好注意下。

下面看下关键模块的设置

1.2.1 ZYNQ IP的设置

增一路FCK_CLK1 为100MHZ(也可以设置其他频率)并且引出到外部提供verilog编程时钟。

wpsB596.tmp

双击S_AXIS设置参数

wpsB5A7.tmp

设置如下

wpsB5A8.tmp

双击FIFO 进行如下设置

wpsB5A9.tmp

由于只有写DMA通道,因此不用勾选读DMA通道

wpsB5B9.tmp

既然只用到了DMA写通道,也就只要使用1路中断资源。

wpsB5BA.tmp

1.3 PS部分

相对于《S03_CH01_AXI_DMA_LOOP 环路测试》中的代码,本章代码只有DMA的接收部分。在main.c源码中,实现了数据DMA的测速,并且通过OLED显示出来。为了实现测试,有增加了定时间中断,定时器每过0.5S中断一次。

中断初始化函数,如下

表1-3-1 init_intr_sys函数

int init_intr_sys(void)

{

DMA_Intr_Init(&AxiDma,0);//initial interrupt system

Timer_init(&Timer,TIMER_LOAD_VALUE,0);

Init_Intr_System(&Intc); // initial DMA interrupt system

Setup_Intr_Exception(&Intc);

DMA_Setup_Intr_System(&Intc,&AxiDma,TX_INTR_ID,RX_INTR_ID);//setup dma interrpt system

Timer_Setup_Intr_System(&Intc,&Timer,TIMER_IRPT_INTR);

DMA_Intr_Enable(&Intc,&AxiDma);

}

DMA读测速的部分的原理是计数DMA读传输的次数,然后每过2秒,计算一次速度。通过OLED显示测速。

表1-3-2 测试代码

if(RxDone)

{

RxDone=0;

RX_ready=1;

RX_success++;

}

if(TxDone)

{

TxDone=0;

TX_ready=1;

TX_success++;

}

if(usec==2)

{

usec=0;

sprintf(oled_str,"RX_cnt=%d",RX_success);

xil_printf("%s\r\n",oled_str);

print_message(oled_str,0);

speed_rx = MAX_PKT_LEN*RX_success/1024/1024;

sprintf(oled_str,"RX_sp=%.2fMB/S",speed_rx);

xil_printf("%s\r\n",oled_str);

print_message(oled_str,1);

sprintf(oled_str,"TX_cnt=%d",TX_success);

xil_printf("%s\r\n",oled_str);

print_message(oled_str,2);

speed_tx = (MAX_PKT_LEN)*TX_success/1024/1024;

sprintf(oled_str,"TX_sp=%.2fMB/S",speed_tx);

xil_printf("%s\r\n",oled_str);

print_message(oled_str,3);

RX_success=0;

TX_success=0;

}

定时器中断在第二季《S02_CH08_ ZYNQ 定时器中断实验》已经详细讲解过,至于DMA中断《S03_CH01_AXI_DMA_LOOP 环路测试》中也已经详细讲解,不在过多复述。

1.4 测试结果

wpsB5BB.tmp

wpsB5CC.tmp

wpsB5CD.tmp

wpsB5CE.tmp

wpsB5DF.tmp

posted on 2017-03-01 14:14  米联客小号  阅读(4990)  评论(0编辑  收藏  举报