• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >嵌入式开发 > DSPF28335中I2C读取多路AD怎么配置I2C呢

DSPF28335中I2C读取多路AD怎么配置I2C呢

作者:佚名 字体:[增加 减小] 来源:互联网 时间:2017-06-05

佚名通过本文主要向大家介绍了dspf28335,i2c ad,stm32多路ad采集,多路ad采集,多路ad芯片等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: DSP F28335 中I2C 读取多路AD 怎么配置I2C呢
描述:

I2C ADS1115 ADDSPF28335

如题,我要在开发板中通过I2C总线方式读取 一块ADS1115 芯片上的2路AD 转换结果,现在一路一路的读没有问题,2路或者多路就不行,不知道怎么配置I2C
 我把主程序的代码贴出来,大伙帮忙指导一下吧,感激!
#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File
// Prototype statements for functions found within this file.
void I2CA_Init(void);
Uint16 I2CA_WriteData(struct I2CMSG *msg);
Uint16 I2CA_ReadData(struct I2CMSG *msg);
interrupt void i2c_int1a_isr(void);
void InitEPwm1Example(void);
#define I2C_SLAVE_ADDR        0x48  //如果要用第二组AD 通道【5、6、7、8】 需要把此处改为0x49
#define I2C_NUMBYTES1          3
#define I2C_NUMBYTES2          1
#define I2C_NUMBYTES3          2
#define I2C_EEPROM_HIGH_ADDR  0x00
#define I2C_EEPROM_LOW_ADDR   0x30
#define I2C_MSGSTAT_WRITE_BUSY1        0x0012
#define I2C_MSGSTAT_INACTIVE1          0x0001
// Global variables
// Two bytes will be used for the outgoing address,
// thus only setup 14 bytes maximum
//------------------------------------------------------------------------------------------------------------------------------
struct I2CMSG I2cMsgOut1 = { I2C_MSGSTAT_SEND_WITHSTOP, I2C_SLAVE_ADDR,
I2C_NUMBYTES1, I2C_EEPROM_HIGH_ADDR, I2C_EEPROM_LOW_ADDR, 0x01, // Msg Byte 1
0x40, // Msg Byte 2  [把0x40改成0x50 外部电源接5和6 对应通道2   把0x40改成0x60,就是通道3  把0x40改成0x70,就是通道4]
0xe3,                   // Msg Byte 3
};
// I2cMsgOut1.NumOfBytes=3;
struct I2CMSG I2cMsgOut2 = { I2C_MSGSTAT_SEND_WITHSTOP, I2C_SLAVE_ADDR,
I2C_NUMBYTES2, I2C_EEPROM_HIGH_ADDR, I2C_EEPROM_LOW_ADDR, 0x00, // Msg Byte 1
};
//I2cMsgOut2.NumOfBytes=1;
struct I2CMSG I2cMsgIn1 = { I2C_MSGSTAT_SEND_NOSTOP, I2C_SLAVE_ADDR,
I2C_NUMBYTES3, I2C_EEPROM_HIGH_ADDR, I2C_EEPROM_LOW_ADDR };
//------------------------------------------------------------------------------------------------------------------------------
struct I2CMSG I2cMsgAD2 = { I2C_MSGSTAT_SEND_WITHSTOP, I2C_SLAVE_ADDR,
I2C_NUMBYTES1, I2C_EEPROM_HIGH_ADDR, I2C_EEPROM_LOW_ADDR, 0x01, // Msg Byte 1
0x50, // Msg Byte 2  [把0x40改成0x50 外部电源接5和6 对应通道2   把0x40改成0x60,就是通道3  把0x40改成0x70,就是通道4]
0xe3,                   // Msg Byte 3
};
struct I2CMSG I2cMsgAD2_2 = { I2C_MSGSTAT_SEND_WITHSTOP, I2C_SLAVE_ADDR,
I2C_NUMBYTES2, I2C_EEPROM_HIGH_ADDR, I2C_EEPROM_LOW_ADDR, 0x00, // Msg Byte 1
};
struct I2CMSG I2cMsgIn2 = { I2C_MSGSTAT_SEND_NOSTOP, I2C_SLAVE_ADDR,
I2C_NUMBYTES3, I2C_EEPROM_HIGH_ADDR, I2C_EEPROM_LOW_ADDR };
//------------------------------------------------------------------------------------------------------------------------------
struct I2CMSG *CurrentMsgPtr; // Used in interrupts
Uint16 Count;
float result;
float result_2;
Uint16 CH;
//Uint16 FailCount;
void main(void) {
Uint16 Error;
Uint16 i;
CurrentMsgPtr = &I2cMsgOut1;
InitSysCtrl();
InitEPwm1Gpio();
//  InitEPwm2Gpio();
//  InitEPwm3Gpio();
//  InitEPwm4Gpio();
InitI2CGpio();
InitEPwm1Example();
DINT;
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
// This is needed to write to EALLOW protected registers
PieVectTable.I2CINT1A = &i2c_int1a_isr;
EDIS;
// This is needed to disable write to EALLOW protected registers
I2CA_Init();
Count = 0;
for (i = 0; i < 2; i++) {
I2cMsgIn1.MsgBuffer[i] = 0x0000;
}
for (i = 0; i < 2; i++) {
I2cMsgIn2.MsgBuffer[i] = 0x0000;
}
// Enable interrupts required for this example
// Enable I2C interrupt 1 in the PIE: Group 8 interrupt 1
PieCtrlRegs.PIEIER8.bit.INTx1 = 1;
// Enable CPU INT8 which is connected to PIE group 8
IER |= M_INT8;
EINT;
for (;;) {
//-----------------------------------AD1----------------------------------------
if (I2cMsgOut1.MsgStatus == I2C_MSGSTAT_SEND_WITHSTOP) {
Error = I2CA_WriteData(&I2cMsgOut1);
if (Error == I2C_SUCCESS) {
CurrentMsgPtr = &I2cMsgOut1;
I2cMsgOut1.MsgStatus = I2C_MSGSTAT_WRITE_BUSY;
}
}
if (I2cMsgOut1.MsgStatus == I2C_MSGSTAT_INACTIVE) {
if (I2cMsgOut2.MsgStatus == I2C_MSGSTAT_SEND_WITHSTOP) {
Error = I2CA_WriteData(&I2cMsgOut2);
if (Error == I2C_SUCCESS) {
CurrentMsgPtr = &I2cMsgOut2;
I2cMsgOut2.MsgStatus = I2C_MSGSTAT_WRITE_BUSY1;
}
}
}
if (I2cMsgOut2.MsgStatus == I2C_MSGSTAT_INACTIVE1) //#define I2C_MSGSTAT_INACTIVE          0x0000
{
// Check incoming message status.
if (I2cMsgIn1.MsgStatus == I2C_MSGSTAT_SEND_NOSTOP) //#define I2C_MSGSTAT_SEND_NOSTOP       0x0020
{
// EEPROM address setup portion
while (I2CA_ReadData(&I2cMsgIn1) != I2C_SUCCESS) //   #define I2C_SUCCESS             0x0000
{
CH = 0x0001;
}
// Update current message point
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • DSPF28335中I2C读取多路AD怎么配置I2C呢

相关文章

  • 2017-06-05 PCI配置端口操作是否存在多线程同步问题
  • 2017-06-17ARM的JTAG接口
  • 2017-06-05 VxWorks55移植UcGUI后,鼠标移动有残影。
  • 2017-06-05 谁有<<VC++NET开发驱动程序详解>>,里面用VC++net怎样设置环境,才能开发驱动啊?
  • 2017-06-05 linux模块加载提示版本不对
  • 2017-06-05 如何像CDN服务一样提供一个子域名让用户cname解析
  • 2017-06-05 Altiumdesigner画原理图,总线部分的NetLabel部分出现错误警告。
  • 2017-06-05 WINCE60USBFN休眠唤醒后系统几乎死掉
  • 2017-06-05 D12TESTSys无法在Win7/Win8下安装,能否通过修改inf解决?
  • 2017-06-05 WINCE60中的BackCar到底是什么???

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • 驱动故障,请各位高手进来指点,谢谢!!急!!!!
    • 请教取cmos时间的问题
    • ser2net的一个端口怎样和两个socket链接通信?
    • 求取网卡mac地址
    • AltiumDesigner2010PCBLogoCreator
    • Linux驱动之USB鼠标问题
    • [求助]OpenwrtMT7620A第二个串口打开
    • 关于ITRON的问题
    • PCImemory
    • 初学驱动程序开发,不知需要哪些基础知识,望老鸟指点

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有