1、参考

UG585

网络笔记

2、理论知识

见中断部分

3、实验目的

练习使用PL侧的普通信号来中断PS处理器。

4、实验过程

建立工程,设置并初始化串口中断,在运行程序之后,如果串口接收到N(1-63)个字节数据,则产生串口中断,Zynq响应中断,将数据从RXFIFO读出之后写入到DDR3预定的地址中。

5、实验平台

Microphase ZUS zynq7020 开发板。 串口使用 uart1[48,49]. DDR选择 MT41J256M16 RE-125,32bit. BANK1 = 1.8v.

6、Vivado 建立工程

block design 如下:

7、SDK的工程程序

/******************************************************************************
*
* 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.
*
******************************************************************************/ #include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xscugic.h"
#include "xscutimer.h"
#include "xparameters.h"
#include "xil_exception.h" #include <unistd.h> //sleep() usleep() #define INTC_DEVICE_ID XPAR_PS7_SCUGIC_0_DEVICE_ID
#define INTC_PL_INTERRUPT_ID XPAR_FABRIC_MY_AXI4LITE_IP_0_PL_TO_ZYNQ_IRQ_INTR
#define INT_TYPE_MASK 0x01
#define INT_TYPE_RISING_EDGE 0X03
#define INT_TYPE_HIGHLEVEL 0X01
#define INT_CFG0_OFFSET 0x00000C00 //(intID/16 )*4
#define INT_ENABLE_OFFSET 0x00000100 //(intID/32 )*4
#define INT_CLEAR_OFFSET 0x00000280 //(intID/32 )*4
#define INT_PRIORITY_OFFSET 0x00000400 //(intID/4 )*4
#define INT_PROCESSORTARGET_OFFSET 0x00000800 //(intID/4 )*4 #define INT_ICCPMR_OFFSET 0xF8F00104
#define INT_ICCICR_OFFSET 0xF8F00100 #define BRAM_BASS_ADDRESS 0X40000000 XScuGic INTCInst; static void PLIRQIntrHandler(void * InstancePtr); //中断处理功能函数
static void CPU_Init(void);
static void IntcTypeSetup(XScuGic *InstancePtr, int intId, int intType) ;
static void IntcTypeEnable(XScuGic *InstancePtr, int intId, int intMask) ;
static void IntcTypeClear(XScuGic *InstancePtr, int intId ) ;
static int InterruptSystemSetup(XScuGic * XScuGicInstancePtr); //中断系统建立
static int IntcInitFunction(u16 DeviceID); //中断控制器初始化功能 int main()
{
init_platform();
CPU_Init(); int status; //中断建立
status = IntcInitFunction(INTC_DEVICE_ID);
if(status != XST_SUCCESS)
return XST_FAILURE ; print(">>>>>>>>>>>> TEST Start >>>>>>>>>>>>>>>>\n\r");
print(" Press the Key for PL begin write data to PS DDR3 : \n\r");
while(1)
{ ;
} cleanup_platform();
return 0;
} // 中断控制器初始化功能
static int IntcInitFunction(u16 DeviceId)
{
XScuGic_Config * IntcConfig ;
int status; printf("Enter the interrupt system >>>>>>\n");
// 第二步, 对中断控制器进行初始化
IntcConfig = XScuGic_LookupConfig(DeviceId); //查找 GIC 的ID
status = XScuGic_CfgInitialize(&INTCInst, IntcConfig, IntcConfig->CpuBaseAddress);
if(status != XST_SUCCESS)
return XST_FAILURE; //第三步,建立中断系统
status = InterruptSystemSetup(&INTCInst);
if(status != XST_SUCCESS)
return XST_FAILURE ; //第四步,GPIO中断连接到GIC上
status = XScuGic_Connect(&INTCInst, INTC_PL_INTERRUPT_ID,
(Xil_ExceptionHandler)PLIRQIntrHandler, (void *)1); if(status != XST_SUCCESS)
return XST_FAILURE ; //******************//
// 参考
IntcTypeSetup(&INTCInst, INTC_PL_INTERRUPT_ID, INT_TYPE_RISING_EDGE); //重要
IntcTypeEnable(&INTCInst, INTC_PL_INTERRUPT_ID, INT_TYPE_MASK); //*********************************//
XScuGic_Enable(&INTCInst, INTC_PL_INTERRUPT_ID); //CIG允许中断 return XST_SUCCESS ;
} static int InterruptSystemSetup (XScuGic * XScuGicInstancePtr)
{
//中断异常的处理,指定该中断异常的处理器
Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,
(Xil_ExceptionHandler)XScuGic_InterruptHandler, XScuGicInstancePtr); Xil_ExceptionEnable(); //异常处理使能 return XST_SUCCESS; } void IntcTypeSetup(XScuGic *InstancePtr, int intId, int intType)
{
//Setup 包括 触发方式配置, 优先级配置,CPU连接。 设置某个中断信息的前提是不影响其他中断设置
int mask; //设置边沿触发方式
mask = XScuGic_DistReadReg(InstancePtr, INT_CFG0_OFFSET + (intId/16)*4); //read ICDICFR *4,因为1个寄存器4个字节
mask &= ~(0X3 << (intId%16)*2); //把读出的值对应2bit,清00,其他保持不变 //*2因为每个中断对应2bit
mask |= intType << ((intId%16)*2); //把清0后的值对应2bit,写01,其他保持不变
XScuGic_DistWriteReg(InstancePtr, INT_CFG0_OFFSET + (intId/16)*4, mask); //WRITE ICDICFR //设置优先级
mask = XScuGic_DistReadReg(InstancePtr, INT_PRIORITY_OFFSET + (intId/4)*4); //read 优先级状态
mask &= ~(0XFE << (intId%4)*8); //把读出的值对应8bit,清00,其他保持不变 //*8因为每个中断对应8bit
mask |= 0XA0 << ((intId%4)*8); //把清0后的值对应8bit,写A0,其他保持不变
XScuGic_DistWriteReg(InstancePtr, INT_PRIORITY_OFFSET + (intId/4)*4, mask); //WRITE ICDICFR //设置处理器CPIID
mask = XScuGic_DistReadReg(InstancePtr, INT_PROCESSORTARGET_OFFSET + (intId/4)*4); //read 优先级状态
mask &= ~(0X03 << (intId%4)*8); //把读出的值对应8bit,清00,其他保持不变 //*8因为每个中断对应8bit
mask |= 0X01 << ((intId%4)*8); //把清0后的值对应8bit,写A0,其他保持不变
XScuGic_DistWriteReg(InstancePtr, INT_PROCESSORTARGET_OFFSET + (intId/4)*4, mask); //WRITE ICDICFR } void IntcTypeEnable(XScuGic *InstancePtr, int intId,int intMask)
{
// 本函数 只包括 使能中断。使能之前先判断是否需要屏蔽
int mask; mask = XScuGic_DistReadReg(InstancePtr, INT_ENABLE_OFFSET + (intId/32)*4);
mask &= ~(0x01 << (intId%32)*1); //把对应的Enable bit 清0
mask |= intMask << ((intId%32)*1); //把对应的Enable bit 与 mask
XScuGic_DistWriteReg(InstancePtr, INT_ENABLE_OFFSET + (intId/32)*4, mask); //WRITE ICDICFR
} void IntcTypeClear(XScuGic *InstancePtr, int intId )
{
//本函数仅包括清楚中断,注意只能清除本中断对应的寄存器位
int mask; mask = XScuGic_DistReadReg(InstancePtr, INT_CLEAR_OFFSET + (intId/32)*4); //read ICDICPR
mask &= ~(0x01 << (intId%32)*1);
mask |= 0x01 << ((intId%32)*1);
XScuGic_DistWriteReg(InstancePtr, INT_CLEAR_OFFSET + (intId/32)*4, mask); //WRITE ICDICPR
} void CPU_Init( )
{
//中断优先级都是A0,优先级高于F0,CPU可接受这些中断
Xil_Out32(INT_ICCPMR_OFFSET,0xF0);
//处理器能接收IRQ,使能中断信号连接到处理器
Xil_Out32(INT_ICCICR_OFFSET,0x07);
} static void PLIRQIntrHandler(void * InstancePtr)
{
//default led all turn off
printf("\n************* test STARAT *********************\n");
int i;
int readdata;
sleep(1); for(i = 0; i < 4; i++)
{
readdata = Xil_In32(BRAM_BASS_ADDRESS+i*4); //读取数据函数。
sleep(1);
printf("the read address is 0x%04x, the read data is 0x%04x.\n", BRAM_BASS_ADDRESS+i*4, readdata);
} printf("\n************* test finish *********************\n");
// ***************************************************** // IntcTypeClear(&INTCInst, INTC_PL_INTERRUPT_ID);
IntcTypeEnable(&INTCInst, INTC_PL_INTERRUPT_ID, INT_TYPE_MASK); }

8 调试结果

ZYNQ 7020学习笔记之PL侧普通信号中断PS的实验的更多相关文章

  1. MiZ702学习笔记9——XADC采集片上数据PS版

    这次借助zynq的内嵌的XADC来采集zynq内部的一些参数: •VCCINT:内部PL核心电压 •VCCAUX:辅助PL电压 •VREFP:XADC正参考电压 •VREFN:XADC负参考电压 •V ...

  2. Oracle学习笔记之PL/SQL编程

           SQL(Structure Query Language)的含义是结构化查询语句,最早由Boyce和Chambedin在1974年提出,称为SEQUEL语言.1976年,IBM公司的Sa ...

  3. 吴裕雄--天生自然ORACLE数据库学习笔记:PL/SQL编程

    set serveroutput on declare a ; b ; c number; begin c:=(a+b)/(a-b); dbms_output.put_line(c); excepti ...

  4. Zynq-Linux移植学习笔记之27UIO机制响应外部中断实现【转】

    转自:https://blog.csdn.net/zhaoxinfan/article/details/80285150 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog ...

  5. 《Linux内核设计的艺术》学习笔记(七)INT 0x15中断

    参考资料: 1. <IBM-PC汇编语言程序设计> 2. http://blog.sina.com.cn/s/blog_5028978101008wk2.html 3. http://ww ...

  6. 《Linux内核设计的艺术》学习笔记(五)INT 0x10中断

    参考书籍: 1. <IBM-PC汇编语言程序设计> 2. http://www.ctyme.com/intr/int-10.htm   ◆ 设置显示方式: 功能号:AH = 00H 调用参 ...

  7. 《Linux内核设计的艺术》学习笔记(二)INT 0x13中断

    参考资料: 1. <IBM-PC汇编语言程序设计> 2. http://blog.sina.com.cn/s/blog_5028978101008wk2.html 3. http://ww ...

  8. PyQt4学习笔记2:事件和信号

    事件是任何 GUI 程序中很重要的部分.所有 GUI 应用都是事件驱动的.一个应用对其生命期产生的不同的事件类型做出反应.事件是主要由应用的用户产生.但是,也可以通过其他方法产生,比如,网络通信,窗口 ...

  9. APUE学习笔记——10.11~10.13 信号集、信号屏蔽字、未决信号

    如有转载,请注明出处:Windeal专栏 首先简述下几个概念的关系: 我们通过信号集建立信号屏蔽字,使得信号发生阻塞,被阻塞的信号即未决信号. 信号集: 信号集:其实就是一系列的信号.用sigset_ ...

随机推荐

  1. Landscaping Gym - 101128F (网络流)

    Problem F: Landscaping \[ Time Limit: 1 s \quad Memory Limit: 256 MiB \] 题意 题意是给出一个\(n*m\)的格子,其中一些是低 ...

  2. 爬虫高性能asyncio+ahttpio

    async实现协程,异步编程 我们都知道,现在的服务器开发对于IO调度的优先级控制权已经不再依靠系统,都希望采用协程的方式实现高效的并发任务,如js.lua等在异步协程方面都做的很强大. python ...

  3. A1136 | 字符串处理、大整数运算

    题目链接: https://www.patest.cn/contests/pat-a-practise/1136 今天是12月17号.最近这几天都有点不在状态.已经整整一周没有练算法了,自从12.3考 ...

  4. vue中的scoped分析以及在element-UI和vux中的应用

    vue使用了单文件组件方式来解耦视图即.vue后缀文件名 单文件组件组成部分: <template> </template> <script> </scrip ...

  5. smartnic

    19年趋势: Intel® 2019网络技术研讨会圆满落幕 SANTOS: Flow and HQoS Acceleration Over DPDK Using Intel Programmable ...

  6. leetcode 337. 打家劫舍iii

    题目描述: 在上次打劫完一条街道之后和一圈房屋后,小偷又发现了一个新的可行窃的地区.这个地区只有一个入口,我们称之为“根”. 除了“根”之外,每栋房子有且只有一个“父“房子与之相连.一番侦察之后,聪明 ...

  7. 列出python库的内置方法

    import cv dir(cv) ['16SC', '16UC', '32FC', '32SC', '64FC', '8SC', '8UC', 'Abs', 'AbsDiff', 'AbsDiffS ...

  8. APP测试要点整理

    APP测试基本流程以及APP测试要点https://www.cnblogs.com/dengqing9393/p/6497068.html 性能测试:https://blog.csdn.net/xia ...

  9. 微信token介绍

    这里的微信token 有以下三种 1.小程序的token  (appid+appsecret=token) 2.一个是第三方平台token(comment_appid+comment_appsecre ...

  10. Refused to execute script from '...' because its MIME type ('') is not executable, and strict MIME type checking is enabled.

    写在前面 部署项目到weblogic上启动首页访问空白, 浏览器控制台报如题错误. web.xml中把响应头添加防止攻击的报文过滤器禁用就行了(仅仅是为了启动), 以下为转载内容, 可以根据需要自行测 ...