TMS320F280049C 学习笔记28 AIO (模拟引脚读取数字信号)_280049c引脚-程序员宅基地

技术标签: DSP  TI DSP学习  280049C  

文章目录

概述

280049C有40个GPIO口,但在复杂应用中可能仍然不够。为了进一步增强DSP功能,28004x系列支持将ADC引脚复用为AIO,用于读取数字信号。

特性

  1. AIO只能读数字信号,不能输出;
  2. 可配置内部上拉电阻;(这点与28035是不同的,28035没有内部上拉电阻)
  3. 过高的dv/dt可能在相邻通道上产生串扰;
  4. 在28004x中AIO对应 Port H 的 GPIO224-GPIO247。
    在这里插入图片描述
    上图出自28004x的数据表。

例程

官方例程中在C:\ti\C2000Ware_DigitalPower_SDK_3_00_01_00\c2000ware\driverlib\f28004x\examples\gpio 中提供了gpio_ex4_aio_external_interrupt 可供参考
在这里插入图片描述

//#############################################################################
//
// FILE:   gpio_ex4_aio_external_interrupt.c
//
// TITLE:  Configure Analog IO (AIO) pin as External Interrupt (XINT)
//
//! \addtogroup driver_example_list
//! <h1>External Interrupt (XINT)</h1>
//!
//! In this example AIO pins are configured as digital inputs. Two other GPIO
//! signals (connected externally to AIO pins) are toggled in software to
//! trigger external interrupt through AIO224 and AIO225 (AIO224 assigned to
//! XINT1 and AIO225 assigned to XINT2). The user is required to externally
//! connect these signals for the program to work properly.  Each interrupt
//! is fired in sequence: XINT1 first and then XINT2.
//!
//! GPIO34 will go high outside of the interrupts and low within the
//! interrupts. This signal can be monitored on a scope.
//!
//! \b External \b Connections \n
//! - Connect GPIO30 to AIO224.  AIO224 will be assigned to XINT1
//! - Connect GPIO31 to AIO225.  AIO225 will be assigned to XINT2
//! - GPIO34 can be monitored on an oscilloscope
//!
//! \b Watch \b Variables \n
//!  - xint1Count for the number of times through XINT1 interrupt
//!  - xint2Count for the number of times through XINT2 interrupt
//!  - loopCount for the number of times through the idle loop
//!
//
//#############################################################################
// $TI Release: F28004x Support Library v1.10.00.00 $
// $Release Date: Tue May 26 17:06:03 IST 2020 $
// $Copyright:
// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
//
// Redistribution and use in source and binary forms, with or without 
// modification, are permitted provided that the following conditions 
// are met:
// 
//   Redistributions of source code must retain the above copyright 
//   notice, this list of conditions and the following disclaimer.
// 
//   Redistributions in binary form must reproduce the above copyright
//   notice, this list of conditions and the following disclaimer in the 
//   documentation and/or other materials provided with the   
//   distribution.
// 
//   Neither the name of Texas Instruments Incorporated nor the names of
//   its contributors may be used to endorse or promote products derived
//   from this software without specific prior written permission.
// 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// $
//#############################################################################

//
// Included Files
//
#include "driverlib.h"
#include "device.h"

//
// Defines
//
// Qualification period at 6 samples in microseconds
#define DELAY   (6.0 * 510.0 * 1000000.0 * (1.0 / DEVICE_SYSCLK_FREQ))

//
// Globals
//
volatile uint32_t xint1Count = 0;
volatile uint32_t xint2Count = 0;
uint32_t loopCount = 0;

//
// Function Prototypes
//
__interrupt void xint1ISR(void);
__interrupt void xint2ISR(void);

//
// Main
//
void main(void)
{
    
    uint32_t xint1CountTemp;
    uint32_t xint2CountTemp;

    //
    // Initialize device clock and peripherals
    //
    Device_init();

    //
    // Disable pin locks and enable internal pullups.
    //
    Device_initGPIO();

    //
    // Initialize PIE and clear PIE registers. Disables CPU interrupts.
    //
    Interrupt_initModule();

    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    //
    Interrupt_initVectorTable();

    //
    // Interrupts that are used in this example are re-mapped to ISR functions
    // found within this file.
    //
    Interrupt_register(INT_XINT1, &xint1ISR);
    Interrupt_register(INT_XINT2, &xint2ISR);

    //
    // Enable XINT interrupts
    //
    Interrupt_enable(INT_XINT1);
    Interrupt_enable(INT_XINT2);

    //
    // Enable Global Interrupt (INTM) and realtime interrupt (DBGM)
    //
    EINT;
    ERTM;

    //
    // GPIO30 & GPIO31 are outputs that will trigger the interrupts through
    // AIO224 and AIO225.  Starting with GPIO30 as high and GPIO31 as low.
    //
    GPIO_writePin(30, 1);
    GPIO_setPinConfig(GPIO_30_GPIO30);
    GPIO_setDirectionMode(30, GPIO_DIR_MODE_OUT);

    GPIO_writePin(31, 0);
    GPIO_setPinConfig(GPIO_31_GPIO31);
    GPIO_setDirectionMode(31, GPIO_DIR_MODE_OUT);

    //
    // AIO224 and AIO225 are inputs and the pins tied to the external interrupts.
    // AIO224 will be synchronous to SYSCLKOUT only.  AIO225 will use a
    // qualification mode of 6 samples. Configure AIO in digital input mode.
    // These AIO pins do not have digital output capability. Setting direction
	// of the AIO pin is not required.
    //
    GPIO_setPinConfig(GPIO_224_GPIO224);
    GPIO_setAnalogMode(224, GPIO_ANALOG_DISABLED);
    GPIO_setQualificationMode(224, GPIO_QUAL_SYNC);

    GPIO_setPinConfig(GPIO_225_GPIO225);
    GPIO_setAnalogMode(225, GPIO_ANALOG_DISABLED);
    GPIO_setQualificationMode(225, GPIO_QUAL_6SAMPLE);

    //
    // Each sampling window will be 510 SYSCLKOUT cycles.  Note that this
    // function actually sets the qualification period for GPIOs 0 through 7
    // (if they are using qualification).
    //
    GPIO_setQualificationPeriod(225, 510);

    //
    // Select AIO224 as XINT1 and AIO225 as XINT2
    //
    GPIO_setInterruptPin(224, GPIO_INT_XINT1);
    GPIO_setInterruptPin(225, GPIO_INT_XINT2);

    //
    // Configure XINT1 to be a triggered by a falling edge and XINT2 to be
    // triggered by a rising edge.
    //
    GPIO_setInterruptType(GPIO_INT_XINT1, GPIO_INT_TYPE_FALLING_EDGE);
    GPIO_setInterruptType(GPIO_INT_XINT2, GPIO_INT_TYPE_RISING_EDGE);

    //
    // Enable XINT1 and XINT2
    //
    GPIO_enableInterrupt(GPIO_INT_XINT1);
    GPIO_enableInterrupt(GPIO_INT_XINT2);

    //
    // GPIO34 will go low inside each interrupt.  Monitor this on a scope.
    //
    GPIO_setPinConfig(GPIO_34_GPIO34);
    GPIO_setDirectionMode(34, GPIO_DIR_MODE_OUT);

    //
    // Loop indefinitely
    //
    while(1)
    {
    
        xint1CountTemp = xint1Count;
        xint2CountTemp = xint2Count;

        //
        // Trigger XINT1
        //
        GPIO_writePin(34, 1);       // GPIO34 is high
        GPIO_writePin(30, 0);       // Lower GPIO30, trigger XINT1

        //
        // Wait until ISR has finished
        //
        while(xint1Count == xint1CountTemp)
        {
    
            ;
        }

        //
        // Trigger XINT2
        //
        GPIO_writePin(34, 1);       // GPIO34 is high
        DEVICE_DELAY_US(DELAY);     // Wait for qual period
        GPIO_writePin(31, 1);       // Raise GPIO31, trigger XINT2

        //
        // Wait until ISR has finished
        //
        while(xint2Count == xint2CountTemp)
        {
    
            ;
        }

        //
        // Check that the counts were incremented properly and get ready
        // to start over.
        //
        if((xint1Count == (xint1CountTemp + 1)) &&
           (xint2Count == (xint2CountTemp + 1)))
        {
    
            loopCount++;
            GPIO_writePin(30, 1);   // Raise GPIO30
            GPIO_writePin(31, 0);   // Lower GPIO31
        }
        else
        {
    
            //
            // Something went wrong
            //
            ESTOP0;
        }
    }
}

//
// xint1ISR - XINT1 ISR
//
__interrupt void xint1ISR(void)
{
    
    //
    // Lower GPIO34 and increment interrupt count
    //
    GPIO_writePin(34, 0);
    xint1Count++;

    //
    // Acknowledge the interrupt
    //
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}

//
// xint2ISR -  XINT2 ISR
//
__interrupt void xint2ISR(void)
{
    
    //
    // Lower GPIO34 and increment interrupt count
    //
    GPIO_writePin(34, 0);
    xint2Count++;

    //
    // Acknowledge the interrupt
    //
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/whyorwhnt/article/details/108145676

智能推荐

BP-1-3 Introduction of C++_in c++, a legal identifier may contain these kinds-程序员宅基地

文章浏览阅读115次。Chapter 01 Introduction of Programming3. Introduction of C++A C++ program must have a function named main defined in only one source document.3.1 Lexer in C++symbol setlettersnumbersspecial characterswordIdentifier is composed of letter_in c++, a legal identifier may contain these kinds of characters:

Http重定向https MPM模块 HTTPd常见配置 sendfile 20190227-程序员宅基地

文章浏览阅读3.4k次。Web访问响应模型(Web I/O)单进程I/O模型:启动一个进程处理用户请求,而且一次只处理一个,多个请求被串行响应多进程I/O模型:并行启动多个进程,每个进程响应一个连接请求复用I/O结构:启动一个进程,同时响应N个连接请求实现方法:多线程模型和事件驱动多线程模型:一个进程生成N个线程,每线程响应一个连接请求事件驱动:一个进程处理N个请求复用的多进程I/O模型:启动M个进程,每个进程响应N个连..._httpd启动需要什么pam模块

vue解决 vue-style-loader ,css-loader错误_!!vue-style-loader!css-loader-程序员宅基地

文章浏览阅读4.2k次。最近在学习vue框架,使用webpack打包vue项目,在执行npm run start的时候 出现如下错误:This dependency was not found:* !!vue-style-loader!css-loader?{"minimize":false,"sourceMap":false}!../../node_modules/vue-loader/lib/style-co..._!!vue-style-loader!css-loader

工业相机的接口选择及比较_相机接口中,传输距离最远的是-程序员宅基地

文章浏览阅读2k次。​在了解工业相机接口之前,让我们大概先了解一下什么是工业相机,一般对工业相机的定义大概是机器视觉系统中的一个关键组件,其最本质的功能就是将光信号转变成有序的电信号。选择合适的相机也是机器视觉系统设计中的重要环节,相机的选择不仅直接决定所采集到的图像分辨率、图像质量等,同时也与整个系统的运行模式直接相关。因为没有一个标准的命名,所以工业相机还被称作工业摄像头、工业摄像机、工业照相机等等。从其芯类型中..._相机接口中,传输距离最远的是

关于在ubuntu常用的一些代码_ubuntu的二级文件系统登录界面代码-程序员宅基地

文章浏览阅读483次。注:最近自己搞了一台谷歌云服务器,自己要试着搭建内网穿透,用到了一些ubuntu的操作语言,先记录下,以后再补充1.切换到最高权限用户 sudo su2.切换目录 - cd #切换到根目录 - cd /root #切换到根目录下的root文件夹 - cd .. #返回到当前目录的上级目录3.查看当前目录下的所有文件 - ls -a #查看所有文件 - ls -a..._ubuntu的二级文件系统登录界面代码

文件修改的基本步骤_改文件-程序员宅基地

文章浏览阅读588次,点赞4次,收藏4次。文件修改的基本步骤Python_改文件

随便推点

Asp.net Mvc 使用EF6 code first 方式连接MySQL总结-程序员宅基地

文章浏览阅读121次。最近由于服务器变更为Linux系统.MsSql for Linux什么时候出来到生产环境使用还是要很长时间的.于是考虑使用Mysql数据库,ORM使用EF.于是先踩下坑顺便记录一下,有需要的tx可以参考下.当你考虑使用EF连接Mysql的时候肯定是已经在网上搜了一堆教程.网上教程基本都是使用控制台做演示.跟着一步步来姿势没错的话可能会正常运行,但项目中使用分层后,把数据层剥离出去,再使用..._mvc6使用ef code

android中popupwindow弹出后,屏幕背景变成半透明_andorid popupwindow弹出后背景-程序员宅基地

文章浏览阅读1k次。android中popupwindow弹出后,屏幕背景变成半透明这个效果很普通。实现的方法也很多。我使用的可能是最简单的一种,就是设置一下getWindows的透明度。不多说上代码/** * 设置添加屏幕的背景透明度 * @param bgAlpha */ public void backgroundAlpha(float bgAlpha) { WindowManager._andorid popupwindow弹出后背景

Backup And Recovery User's Guide-为完全数据库恢复做准备-确定数据库的DBID-程序员宅基地

文章浏览阅读72次。确定数据库的DBID 当需要恢复服务器参数文件或控制文件时,必须知道DBID。应该将DBID和其它数据库基本信息记录在一起。 如果没有数据库的DBID的记录,则可以在不打开数据库的情况下在下面的..._在应用备份恢复时,必须知道目标数据库的dbid

solr <一>用 Java客户端 建索引+分页查询_java 利用solr搜索引擎客户端如何创建索引-程序员宅基地

文章浏览阅读1.8k次。在 solr 3.5 配置及应用(一) 讲过一了 solr 3.5的详细配置,本节我们讲利用solr 的客户端调用solr的应用了!一、利用SolrJ操作solr API 使用SolrJ操作Solr会比利用httpClient来操作Solr要简单。SolrJ是封装了httpClient方法,来操作solr的API的。SolrJ底层还是通过使用httpClient中的方法来完_java 利用solr搜索引擎客户端如何创建索引

sent2vec-程序员宅基地

文章浏览阅读1k次。环境配置EmbedRank在标准数据集上实现了比基于图形的最先进系统更高的F分数,适用于实时处理大量Web数据。利用EmbedRank,我们还为新短语引入了基于嵌入的最大边际相关性(MMR),从而显式地增加了所选关键词的覆盖率和多样性。一项包括200多张选票的用户研究表明,虽然减少短语的语义重叠不会导致F分的增加,但我们的高度多样性选择是人类更喜欢的。保证了关键词的两个最具挑战性的性质:由候选短语与整个文档的嵌入距离获得的信息性;由候选短语之间的距离表示的多样性。文章目录环境配置相关信息装置本_sent2vec

Pycharm使用技巧(转载)-程序员宅基地

文章浏览阅读305次。Pycharm使用技巧(转载)转载自:http://www.cnblogs.com/cloudtj/articles/5980666.htmlpycharm使用技巧https://python.freelycode.com/contribution/detail/29https://python.freelycode.com/contribution/detail..._pycharm映射的web路径是指什么