找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1842|回复: 0
打印 上一主题 下一主题
收起左侧

AD7148芯片初始化读取数据源码

[复制链接]
跳转到指定楼层
楼主
ID:288615 发表于 2018-3-7 11:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. ***************************************************************/
  2. #include  <msp430x14x.h>
  3. #include  "BoardConfig.h"
  4. #include  "UART.h"
  5. #include  "I2C.h"
  6. #include  "AD7148.h"




  7. /*********************主函数模块***********************************
  8. * 名称:main
  9. * 功能:串口设置->7148设置->引发中断
  10. ******************************************************************/
  11. int main( void )
  12. {
  13. //unsigned char j,i,aaa[]="\nHello World!";
  14.   // Stop watchdog timer to prevent time out reset
  15.   WDTCTL = WDTPW + WDTHOLD;
  16.   Sys_Ini();
  17.   ini_uart();
  18.   _EINT();   //打开串口
  19.   starti2c();
  20.   //第一步设置
  21. SETUP_7148_a(0x00,0x80,0x00,0x02);
  22.   SETUP_7148_a(0x00,0x81,0x10,0x00);
  23.   SETUP_7148_a(0x00,0x82,0x01,0x00);
  24.   SETUP_7148_a(0x00,0x83,0x18,0x18);
  25.   SETUP_7148_a(0x00,0x84,0x00,0x00);
  26.   SETUP_7148_a(0x00,0x85,0xff,0xff);
  27.   SETUP_7148_a(0x00,0x86,0xff,0xff);
  28.   SETUP_7148_a(0x00,0x87,0x00,0x00);
  29.     //Stage1
  30.   SETUP_7148_a(0x00,0x88,0x00,0x08);
  31.   SETUP_7148_a(0x00,0x89,0x10,0x00);
  32.   SETUP_7148_a(0x00,0x8a,0x01,0x00);
  33.   SETUP_7148_a(0x00,0x8b,0x18,0x18);
  34.   SETUP_7148_a(0x00,0x8c,0x00,0x00);
  35.   SETUP_7148_a(0x00,0x8d,0xff,0xff);
  36.   SETUP_7148_a(0x00,0x8e,0xff,0xff);
  37.   SETUP_7148_a(0x00,0x8f,0x00,0x00);
  38.     //Stage2
  39.   SETUP_7148_a(0x00,0x90,0x00,0x20);
  40.   SETUP_7148_a(0x00,0x91,0x10,0x00);
  41.   SETUP_7148_a(0x00,0x92,0x01,0x00);
  42.   SETUP_7148_a(0x00,0x93,0x18,0x18);
  43.   SETUP_7148_a(0x00,0x94,0x00,0x00);
  44.   SETUP_7148_a(0x00,0x95,0xff,0xff);
  45.   SETUP_7148_a(0x00,0x96,0xff,0xff);
  46.   SETUP_7148_a(0x00,0x97,0x00,0x00);
  47.     //Stage3
  48.   SETUP_7148_a(0x00,0x98,0x00,0x80);
  49.   SETUP_7148_a(0x00,0x99,0x10,0x00);
  50.   SETUP_7148_a(0x00,0x9a,0x02,0x01);
  51.   SETUP_7148_a(0x00,0x9b,0x18,0x18);
  52.   SETUP_7148_a(0x00,0x9c,0x00,0x00);
  53.   SETUP_7148_a(0x00,0x9d,0xff,0xff);
  54.   SETUP_7148_a(0x00,0x9e,0xff,0xff);
  55.   SETUP_7148_a(0x00,0x9f,0x00,0x00);
  56.     //Stage4
  57.   SETUP_7148_a(0x00,0xa0,0x02,0x00);
  58.   SETUP_7148_a(0x00,0xa1,0x10,0x00);
  59.   SETUP_7148_a(0x00,0xa2,0x01,0x00);
  60.   SETUP_7148_a(0x00,0xa3,0x18,0x18);
  61.   SETUP_7148_a(0x00,0xa4,0x00,0x00);
  62.   SETUP_7148_a(0x00,0xa5,0xff,0xff);
  63.   SETUP_7148_a(0x00,0xa6,0xff,0xff);
  64.   SETUP_7148_a(0x00,0xa7,0x00,0x00);
  65.     //Stage5
  66.   SETUP_7148_a(0x00,0xa8,0x08,0x00);
  67.   SETUP_7148_a(0x00,0xa9,0x10,0x00);
  68.   SETUP_7148_a(0x00,0xaa,0x01,0x00);
  69.   SETUP_7148_a(0x00,0xab,0x18,0x18);
  70.   SETUP_7148_a(0x00,0xac,0x00,0x00);
  71.   SETUP_7148_a(0x00,0xad,0xff,0xff);
  72.   SETUP_7148_a(0x00,0xae,0xff,0xff);
  73.   SETUP_7148_a(0x00,0xaf,0x00,0x00);
  74.     //Stage6
  75.   SETUP_7148_a(0x00,0xb0,0x20,0x00);
  76.   SETUP_7148_a(0x00,0xb1,0x10,0x00);
  77.   SETUP_7148_a(0x00,0xb2,0x01,0x00);
  78.   SETUP_7148_a(0x00,0xb3,0x18,0x18);
  79.   SETUP_7148_a(0x00,0xb4,0x00,0x00);
  80.   SETUP_7148_a(0x00,0xb5,0xff,0xff);
  81.   SETUP_7148_a(0x00,0xb6,0xff,0xff);
  82.   SETUP_7148_a(0x00,0xb7,0x00,0x00);
  83.     //Stage7
  84.   SETUP_7148_a(0x00,0xb8,0x00,0x00);
  85.   SETUP_7148_a(0x00,0xb9,0x10,0x02);
  86.   SETUP_7148_a(0x00,0xba,0x02,0x00);
  87.   SETUP_7148_a(0x00,0xbb,0x18,0x18);
  88.   SETUP_7148_a(0x00,0xbc,0x00,0x00);
  89.   SETUP_7148_a(0x00,0xbd,0xff,0xff);
  90.   SETUP_7148_a(0x00,0xbe,0xff,0xff);
  91.   SETUP_7148_a(0x00,0xbf,0x00,0x00);
  92.   //第二步设置
  93.   SETUP_7148_a(0x00,0x00,0x00,0x72);
  94.   SETUP_7148_a(0x00,0x01,0x00,0x00);
  95.   SETUP_7148_a(0x00,0x02,0x32,0x30);
  96.   SETUP_7148_a(0x00,0x03,0x04,0x19);
  97.   SETUP_7148_a(0x00,0x04,0x08,0x32);
  98.   SETUP_7148_a(0x00,0x05,0x00,0x00);
  99.   SETUP_7148_a(0x00,0x06,0x00,0x00);
  100.   SETUP_7148_a(0x00,0x07,0x00,0xff);
  101.   //第三步设置
  102.   SETUP_7148_a(0x00,0x01,0x00,0xff);
  103.   key_init();  
  104.   
  105.   __enable_interrupt();                                      //开启总中断,这一步没有的话,所有的中断都不能触发
  106.   
  107.   while(1)
  108.   {
  109.     dat[0] =0;
  110.     dat[1] =0;
  111.       sendbyte_uart(0xa1);
  112.       sendbyte_uart(0xa5);
  113.     get7148value(&MRD[1],&MRD[0],0x00,0x0b);
  114.     get7148value(&MRD[1],&MRD[0],0x00,0x0c);
  115.     get7148value(&MRD[1],&MRD[0],0x00,0x0d);
  116.     get7148value(&MRD[1],&MRD[0],0x00,0x0e);
  117.     get7148value(&MRD[1],&MRD[0],0x00,0x0f);
  118.     get7148value(&MRD[1],&MRD[0],0x00,0x10);
  119.     get7148value(&MRD[1],&MRD[0],0x00,0x11);
  120.     get7148value(&MRD[1],&MRD[0],0x00,0x12);
  121.       sendbyte_uart(dat[0]);
  122.       sendbyte_uart(dat[1]);
  123.     delay(1);
  124.   };
  125. }
复制代码


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表