ZYNQ EMIO MIO

2024-03-21 07:28
文章标签 zynq mio emio

本文主要是介绍ZYNQ EMIO MIO,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1 概述

先来了解GPIO的BANK分布,在UG585文档GPIO一章中可以看到GPIO是有4个BANK,
注意与MIO的BANK区分。
BANK0 控制32个信号,BANK1控制22个信号,总共是MIO的54个引脚,也就是诸如
SPI,I2C,USB,SD 等 PS 端外设接口;
BANK2和BANK3共能控制64个PL端引脚,注意每一组都有三个信号,输入EMIOGPIOI,
输出EMIOGPIOO,输出使能EMIOGPIOTN,类似于三态门,共192个信号。可以连接到PL
端引脚,通过PS控制信号。
在这里插入图片描述

下图为GPIO的控制框图,实验中会用到输出部分的寄存器,数据寄存器DATA,数据掩
码寄存器MASK_DATA_LSW,MASK_DATA_MSW,方向控制寄存器DIRM,输出使能控制
器OEN。
在这里插入图片描述
在这里插入图片描述

2 MIO 按键中断

前面介绍了MIO作为输出控制LED灯,这里讲一下利用MIO作为按键输入控制LED灯。

  1. 通过UG585文档看下GPIO的结构图,中断的寄存器:
    INT_MASK:中断掩码
    INT_DIS: 中断关闭
    INT_EN: 中断使能
    INT_TYPE: 中断类型,设置电平敏感还是边沿敏感
    INT_POLARITY: 中断极性,设置低电平或下降沿还是高电平或上升沿
    INT_ANY: 边沿触发方式,需要INT_TYPE设置为边沿敏感才能使用
    设置中断产生方式时需要INT_TYPE、INT_POLARITY、INT_ANY配合使用。具体寄存器含义请参
    考UG585 Register Details 部分。
    在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

/******************************************************************************
*
* 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 "sleep.h"
#include "xgpiops.h"#define GPIO_DEVICE_ID		XPAR_XGPIOPS_0_DEVICE_ID/** The following are declared globally so they are zeroed and can be* easily accessible from a debugger.*/
XGpioPs Gpio;	/* The driver instance for GPIO Device. */int main()
{init_platform();int Status;XGpioPs_Config *ConfigPtr;/* Initialize the GPIO driver. */ConfigPtr = XGpioPs_LookupConfig(GPIO_DEVICE_ID);Status = XGpioPs_CfgInitialize(&Gpio, ConfigPtr,ConfigPtr->BaseAddr);if (Status != XST_SUCCESS) {return XST_FAILURE;}/** Set the direction for the pin to be output and* Enable the Output enable for the LED Pin.*/XGpioPs_SetDirectionPin(&Gpio, 54, 1);XGpioPs_SetDirectionPin(&Gpio, 55, 1);XGpioPs_SetDirectionPin(&Gpio, 56, 1);XGpioPs_SetDirectionPin(&Gpio, 57, 1);XGpioPs_SetDirectionPin(&Gpio, 58, 1);XGpioPs_SetDirectionPin(&Gpio, 59, 1);XGpioPs_SetDirectionPin(&Gpio, 60, 1);XGpioPs_SetDirectionPin(&Gpio, 61, 1);XGpioPs_SetDirectionPin(&Gpio, 62, 1);XGpioPs_SetDirectionPin(&Gpio, 63, 1);XGpioPs_SetOutputEnablePin(&Gpio, 54, 1);XGpioPs_SetOutputEnablePin(&Gpio, 55, 1);XGpioPs_SetOutputEnablePin(&Gpio, 56, 1);XGpioPs_SetOutputEnablePin(&Gpio, 57, 1);XGpioPs_SetOutputEnablePin(&Gpio, 58, 1);XGpioPs_SetOutputEnablePin(&Gpio, 59, 1);XGpioPs_SetOutputEnablePin(&Gpio, 60, 1);XGpioPs_SetOutputEnablePin(&Gpio, 61, 1);XGpioPs_SetOutputEnablePin(&Gpio, 62, 1);XGpioPs_SetOutputEnablePin(&Gpio, 63, 1);while(1){/* Set the GPIO output to be low. */XGpioPs_WritePin(&Gpio, 54, 0x0);XGpioPs_WritePin(&Gpio, 55, 0x0);XGpioPs_WritePin(&Gpio, 56, 0x0);XGpioPs_WritePin(&Gpio, 57, 0x0);XGpioPs_WritePin(&Gpio, 58, 0x0);XGpioPs_WritePin(&Gpio, 59, 0x0);XGpioPs_WritePin(&Gpio, 60, 0x0);XGpioPs_WritePin(&Gpio, 61, 0x0);XGpioPs_WritePin(&Gpio, 62, 0x0);XGpioPs_WritePin(&Gpio, 63, 0x0);sleep(1);print("Hello World\n\r");/* Set the GPIO output to be high. */XGpioPs_WritePin(&Gpio, 54, 0x1);XGpioPs_WritePin(&Gpio, 55, 0x1);XGpioPs_WritePin(&Gpio, 56, 0x1);XGpioPs_WritePin(&Gpio, 57, 0x1);XGpioPs_WritePin(&Gpio, 58, 0x1);XGpioPs_WritePin(&Gpio, 59, 0x1);XGpioPs_WritePin(&Gpio, 60, 0x1);XGpioPs_WritePin(&Gpio, 61, 0x1);XGpioPs_WritePin(&Gpio, 62, 0x1);XGpioPs_WritePin(&Gpio, 63, 0x1);sleep(1);}cleanup_platform();return 0;
}

带按键中断的代码

/******************************************************************************
*
* 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 "xscugic.h"
#include "xil_printf.h"
#include "sleep.h"
#include "xgpiops.h"#define GPIO_DEVICE_ID		XPAR_XGPIOPS_0_DEVICE_ID
#define INTC_DEVICE_ID	    XPAR_SCUGIC_SINGLE_DEVICE_ID
#define KEY_INTR_ID         XPAR_XGPIOPS_0_INTR#define EMIO_LD0  58
#define EMIO_LD1  59
#define EMIO_LD2  60
#define EMIO_LD3  61/** The following are declared globally so they are zeroed and can be* easily accessible from a debugger.*/
XGpioPs Gpio;	/* The driver instance for GPIO Device. */
int key_flag ;
XScuGic INTCInst;int IntrInitFuntion(XScuGic *InstancePtr, u16 DeviceId, XGpioPs *GpioInstancePtr);
void GpioHandler(void *CallbackRef);int main()
{init_platform();int Status;XGpioPs_Config *ConfigPtr;int key_val  = 0 ;key_flag = 0 ;/* Initialize the GPIO driver. */ConfigPtr = XGpioPs_LookupConfig(GPIO_DEVICE_ID);Status = XGpioPs_CfgInitialize(&Gpio, ConfigPtr,ConfigPtr->BaseAddr);if (Status != XST_SUCCESS) {return XST_FAILURE;}/** Set the direction for the pin to be output and* Enable the Output enable for the LED Pin.*/XGpioPs_SetDirectionPin(&Gpio, 54, 1);XGpioPs_SetDirectionPin(&Gpio, 55, 1);XGpioPs_SetDirectionPin(&Gpio, 56, 1);XGpioPs_SetDirectionPin(&Gpio, 57, 1);XGpioPs_SetDirectionPin(&Gpio, 58, 1);XGpioPs_SetDirectionPin(&Gpio, 59, 1);XGpioPs_SetDirectionPin(&Gpio, 60, 1);XGpioPs_SetDirectionPin(&Gpio, 61, 1);XGpioPs_SetDirectionPin(&Gpio, 62, 1);XGpioPs_SetDirectionPin(&Gpio, 63, 1);XGpioPs_SetOutputEnablePin(&Gpio, 54, 1);XGpioPs_SetOutputEnablePin(&Gpio, 55, 1);XGpioPs_SetOutputEnablePin(&Gpio, 56, 1);XGpioPs_SetOutputEnablePin(&Gpio, 57, 1);XGpioPs_SetOutputEnablePin(&Gpio, 58, 1);XGpioPs_SetOutputEnablePin(&Gpio, 59, 1);XGpioPs_SetOutputEnablePin(&Gpio, 60, 1);XGpioPs_SetOutputEnablePin(&Gpio, 61, 1);XGpioPs_SetOutputEnablePin(&Gpio, 62, 1);XGpioPs_SetOutputEnablePin(&Gpio, 63, 1);//KEY/** Set the direction for the pin to be input.* Set interrupt type as rising edge and enable gpio interrupt*/XGpioPs_SetDirectionPin(&Gpio, 64, 0);XGpioPs_SetIntrTypePin(&Gpio, 64, XGPIOPS_IRQ_TYPE_EDGE_RISING) ;XGpioPs_IntrEnablePin(&Gpio, 64) ;XGpioPs_SetDirectionPin(&Gpio, 65, 0);XGpioPs_SetDirectionPin(&Gpio, 66, 0);XGpioPs_SetDirectionPin(&Gpio, 67, 0);//SWXGpioPs_SetDirectionPin(&Gpio, 68, 0);XGpioPs_SetDirectionPin(&Gpio, 69, 0);/** sets up the interrupt system*/Status = IntrInitFuntion(&INTCInst, 64, &Gpio) ;if (Status != XST_SUCCESS)return XST_FAILURE ;while(1){/* Set the GPIO output to be low. */XGpioPs_WritePin(&Gpio, 54, 0x0);XGpioPs_WritePin(&Gpio, 55, 0x0);XGpioPs_WritePin(&Gpio, 56, 0x0);XGpioPs_WritePin(&Gpio, 57, 0x0);XGpioPs_WritePin(&Gpio, 58, 0x0);XGpioPs_WritePin(&Gpio, 59, 0x0);XGpioPs_WritePin(&Gpio, 60, XGpioPs_ReadPin(&Gpio,68));XGpioPs_WritePin(&Gpio, 61, XGpioPs_ReadPin(&Gpio,69));//XGpioPs_WritePin(&Gpio, 62, 0x0);XGpioPs_WritePin(&Gpio, 63, 0x0);if (key_flag){XGpioPs_WritePin(&Gpio, 62, key_val) ;key_val = ~key_val ;key_flag = 0 ;}sleep(1);print("Hello World\n\r");/* Set the GPIO output to be high. */XGpioPs_WritePin(&Gpio, 54, 0x1);XGpioPs_WritePin(&Gpio, 55, 0x1);XGpioPs_WritePin(&Gpio, 56, 0x1);XGpioPs_WritePin(&Gpio, 57, 0x1);XGpioPs_WritePin(&Gpio, 58, 0x1);XGpioPs_WritePin(&Gpio, 59, 0x1);//XGpioPs_WritePin(&Gpio, 60, 0x1);//XGpioPs_WritePin(&Gpio, 61, 0x1);//XGpioPs_WritePin(&Gpio, 62, 0x1);XGpioPs_WritePin(&Gpio, 63, 0x1);sleep(1);}cleanup_platform();return 0;
}int IntrInitFuntion(XScuGic *InstancePtr, u16 DeviceId, XGpioPs *GpioInstancePtr)
{XScuGic_Config *IntcConfig;int Status ;/** Initialize the interrupt controller driver so that it is ready to* use.*/IntcConfig = XScuGic_LookupConfig(INTC_DEVICE_ID);Status = XScuGic_CfgInitialize(InstancePtr, IntcConfig, IntcConfig->CpuBaseAddress) ;if (Status != XST_SUCCESS)return XST_FAILURE ;/** set priority and trigger type*/XScuGic_SetPriorityTriggerType(InstancePtr, KEY_INTR_ID,0xA0, 0x3);/** Connect the device driver handler that will be called when an* interrupt for the device occurs, the handler defined above performs* the specific interrupt processing for the device.*/Status = XScuGic_Connect(InstancePtr, KEY_INTR_ID,(Xil_ExceptionHandler)GpioHandler,(void *)GpioInstancePtr) ;if (Status != XST_SUCCESS)return XST_FAILURE ;/** Enable the interrupt for the device.*/XScuGic_Enable(InstancePtr, KEY_INTR_ID) ;Xil_ExceptionInit();Xil_ExceptionRegisterHandler(XIL_EXCEPTION_ID_INT,(Xil_ExceptionHandler)XScuGic_InterruptHandler,InstancePtr);Xil_ExceptionEnable();return XST_SUCCESS ;}void GpioHandler(void *CallbackRef)
{XGpioPs *GpioInstancePtr = (XGpioPs *)CallbackRef ;int Int_val ;Int_val = XGpioPs_IntrGetStatusPin(GpioInstancePtr, 64) ;/** Clear interrupt.*/XGpioPs_IntrClearPin(GpioInstancePtr, 64) ;if (Int_val)key_flag = 1 ;
}

这篇关于ZYNQ EMIO MIO的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/832081

相关文章

ZYNQ LWIP (RAW API) UDP函数学习

1 RAW API接口 RAW API是基于回调函数实现的API接口,它是很底层的API接口,这需要开发者对LwIP有较深的了解才能很好使用它,RAW API的核心就是对控制块的处理,因为对于报文数据的处理、注册回调函数等都是需要开发者自己去实现,都是比较麻烦的,但是有一个优点,那就是处理数据效率高。 2 RAW API的UDP函数说明 udp_new()–新建控制块 在使用UDP协议进行通

ZYNQ MPSOC FPGA 仿真 教程

1. **FPGA与MPSOC**: FPGA (Field Programmable Gate Array) 是一种可以通过编程配置的集成电路,适用于各种应用和功能。MPSOC (Multi-Processor System on Chip) 是集成了多个处理器(通常是微处理器)的系统芯片,用于处理复杂的应用,如图像处理、网络通信等。 2. **仿真与分析**:    - **仿

【ZYNQ MPSoC开发】lwIP TCP发送用于数据缓存的软件FIFO设计

设计背景        任务是在ZYNQ的PS上使用裸机运行lwIP协议栈使用TCP把PL端通过AXI DMA传来的将近100K采样率的ADC数据发送出去,但由于数据带宽很大,有853.3mbps,所以在每一次AXI DMA简单传输结束后,lwIP未必有足够的发送buffer立即把数据发送走,如果是发送完再进行下一次简单传输的思路,则会很大地限制了整个系统的带宽,一个简单的思路是每次传输完成后判

petalinux,Zynq UltraScale+ MPSoC;WARNING: Failed to load PMUFW, doesn't exist in pre-built.

petalinux-package --pmufw ./images/linux/pmufw.elf 这个参数貌似没有生效; 解决办法: cp images/linux/pmufw.elf ./pre-built/linux/images/

江山易改本性难移之ZYNQ SDK API函数笔记(UART)

初学Xilinx ZYNQ SDK的开发,下面记录使用到的API函数及自己的理解。若有误,还请指教。 UART函数 常用编程步骤: 1.查找输入设备的ID查找设备; 2.输入的配置信息初始化; 3.设置工作模式; 4.设置波特率; 5.设置RxFIFO的中断触发等级; 6.设置接收超时时间; 7.设置UART的中断触发方式 配置UART只需要以上5个步骤,其中6、7是笔者做串口不定

江山易改本性难移之ZYNQ SDK API函数笔记(Timer)

初学Xilinx ZYNQ SDK的开发,下面记录使用到的API函数及自己的理解。若有误,还请指教。 Timer函数 常用编程步骤: 1.查找输入设备的ID查找设备; 2.输入的配置信息初始化; 3.加载计数周期; 4.设置自动装载模式; 5.启动定时器; 配置GPIO只需要以上5个步骤。 1、XGpioPs_Config *XGpioPs_LookupConfig(u16 Devi

万变不离其宗之ZYNQ串口介绍

导语     串口是我们在设计程序中最常用的接口,串口是硬件系统运行状态的忠实打印者,可以完成数据的传输、log输出等功能。 1.串口介绍           通信的两种方式:串行通信、并行通信           串行通信方式分为:同步通信、异步通信          关于传输方向:单工、半双工、全双工 UART(异步串行通信)            ZYNQ的

4 - ZYNQ 信号、接口与引脚

文章目录 1 ZYNQ信号、接口与引脚1.1 电源引脚1.2 PS信号引脚1.3 PL信号引脚1.4 PS和PL交互接口 1 ZYNQ信号、接口与引脚 ZYNQ的信号、接口与引脚如下图所示,主要分为: PS部分PL部分PS和PL交互部分PS和PL共用部分(如JTAG) 1.1 电源引脚 PS与PL部分均需要多种电平的供电电源,电源需要从特定的电源引脚接入芯片,相关电源

【ZYNQ MPSoC开发】PS裸机多核程序的固化

写在前面        多核程序的固化总体操作流程与单核程序固化相同,针对本文中的一些操作,大家如果有不清楚的,可以参考我之前写的单核固化的博客。 共通前置步骤        这是区别于单核固话的主要不同之处。以我的程序为例,我用到了两个核心,分别跑在A53_0和A53_1上,结构如下图所示:        1,首先对各个核心的应用程序都build好,生成.elf文件。

ZYNQ 7020 学习记录-1点灯

系列文章目录 1.点灯 文章目录 系列文章目录前言一、ZYNQ是什么?二、FPGA开发流程1.流程图2.工程管理3.需求分析4.系统框图5.编写RTL代码6.Modelsim 手动仿真7.Vivado工程 总结 前言 由于研究生课题组所研制的设备HIGH-POWER SHM SYSTEM是基于ZYNQ的,以下是本人自学ZYNQ的学习记录,所用板卡为:基于 XILINX Z