标题:
AD7148芯片初始化读取数据源码
[打印本页]
作者:
s496868118
时间:
2018-3-7 11:38
标题:
AD7148芯片初始化读取数据源码
***************************************************************/
#include <msp430x14x.h>
#include "BoardConfig.h"
#include "UART.h"
#include "I2C.h"
#include "AD7148.h"
/*********************主函数模块***********************************
* 名称:main
* 功能:串口设置->7148设置->引发中断
******************************************************************/
int main( void )
{
//unsigned char j,i,aaa[]="\nHello World!";
// Stop watchdog timer to prevent time out reset
WDTCTL = WDTPW + WDTHOLD;
Sys_Ini();
ini_uart();
_EINT(); //打开串口
starti2c();
//第一步设置
SETUP_7148_a(0x00,0x80,0x00,0x02);
SETUP_7148_a(0x00,0x81,0x10,0x00);
SETUP_7148_a(0x00,0x82,0x01,0x00);
SETUP_7148_a(0x00,0x83,0x18,0x18);
SETUP_7148_a(0x00,0x84,0x00,0x00);
SETUP_7148_a(0x00,0x85,0xff,0xff);
SETUP_7148_a(0x00,0x86,0xff,0xff);
SETUP_7148_a(0x00,0x87,0x00,0x00);
//Stage1
SETUP_7148_a(0x00,0x88,0x00,0x08);
SETUP_7148_a(0x00,0x89,0x10,0x00);
SETUP_7148_a(0x00,0x8a,0x01,0x00);
SETUP_7148_a(0x00,0x8b,0x18,0x18);
SETUP_7148_a(0x00,0x8c,0x00,0x00);
SETUP_7148_a(0x00,0x8d,0xff,0xff);
SETUP_7148_a(0x00,0x8e,0xff,0xff);
SETUP_7148_a(0x00,0x8f,0x00,0x00);
//Stage2
SETUP_7148_a(0x00,0x90,0x00,0x20);
SETUP_7148_a(0x00,0x91,0x10,0x00);
SETUP_7148_a(0x00,0x92,0x01,0x00);
SETUP_7148_a(0x00,0x93,0x18,0x18);
SETUP_7148_a(0x00,0x94,0x00,0x00);
SETUP_7148_a(0x00,0x95,0xff,0xff);
SETUP_7148_a(0x00,0x96,0xff,0xff);
SETUP_7148_a(0x00,0x97,0x00,0x00);
//Stage3
SETUP_7148_a(0x00,0x98,0x00,0x80);
SETUP_7148_a(0x00,0x99,0x10,0x00);
SETUP_7148_a(0x00,0x9a,0x02,0x01);
SETUP_7148_a(0x00,0x9b,0x18,0x18);
SETUP_7148_a(0x00,0x9c,0x00,0x00);
SETUP_7148_a(0x00,0x9d,0xff,0xff);
SETUP_7148_a(0x00,0x9e,0xff,0xff);
SETUP_7148_a(0x00,0x9f,0x00,0x00);
//Stage4
SETUP_7148_a(0x00,0xa0,0x02,0x00);
SETUP_7148_a(0x00,0xa1,0x10,0x00);
SETUP_7148_a(0x00,0xa2,0x01,0x00);
SETUP_7148_a(0x00,0xa3,0x18,0x18);
SETUP_7148_a(0x00,0xa4,0x00,0x00);
SETUP_7148_a(0x00,0xa5,0xff,0xff);
SETUP_7148_a(0x00,0xa6,0xff,0xff);
SETUP_7148_a(0x00,0xa7,0x00,0x00);
//Stage5
SETUP_7148_a(0x00,0xa8,0x08,0x00);
SETUP_7148_a(0x00,0xa9,0x10,0x00);
SETUP_7148_a(0x00,0xaa,0x01,0x00);
SETUP_7148_a(0x00,0xab,0x18,0x18);
SETUP_7148_a(0x00,0xac,0x00,0x00);
SETUP_7148_a(0x00,0xad,0xff,0xff);
SETUP_7148_a(0x00,0xae,0xff,0xff);
SETUP_7148_a(0x00,0xaf,0x00,0x00);
//Stage6
SETUP_7148_a(0x00,0xb0,0x20,0x00);
SETUP_7148_a(0x00,0xb1,0x10,0x00);
SETUP_7148_a(0x00,0xb2,0x01,0x00);
SETUP_7148_a(0x00,0xb3,0x18,0x18);
SETUP_7148_a(0x00,0xb4,0x00,0x00);
SETUP_7148_a(0x00,0xb5,0xff,0xff);
SETUP_7148_a(0x00,0xb6,0xff,0xff);
SETUP_7148_a(0x00,0xb7,0x00,0x00);
//Stage7
SETUP_7148_a(0x00,0xb8,0x00,0x00);
SETUP_7148_a(0x00,0xb9,0x10,0x02);
SETUP_7148_a(0x00,0xba,0x02,0x00);
SETUP_7148_a(0x00,0xbb,0x18,0x18);
SETUP_7148_a(0x00,0xbc,0x00,0x00);
SETUP_7148_a(0x00,0xbd,0xff,0xff);
SETUP_7148_a(0x00,0xbe,0xff,0xff);
SETUP_7148_a(0x00,0xbf,0x00,0x00);
//第二步设置
SETUP_7148_a(0x00,0x00,0x00,0x72);
SETUP_7148_a(0x00,0x01,0x00,0x00);
SETUP_7148_a(0x00,0x02,0x32,0x30);
SETUP_7148_a(0x00,0x03,0x04,0x19);
SETUP_7148_a(0x00,0x04,0x08,0x32);
SETUP_7148_a(0x00,0x05,0x00,0x00);
SETUP_7148_a(0x00,0x06,0x00,0x00);
SETUP_7148_a(0x00,0x07,0x00,0xff);
//第三步设置
SETUP_7148_a(0x00,0x01,0x00,0xff);
key_init();
__enable_interrupt(); //开启总中断,这一步没有的话,所有的中断都不能触发
while(1)
{
dat[0] =0;
dat[1] =0;
sendbyte_uart(0xa1);
sendbyte_uart(0xa5);
get7148value(&MRD[1],&MRD[0],0x00,0x0b);
get7148value(&MRD[1],&MRD[0],0x00,0x0c);
get7148value(&MRD[1],&MRD[0],0x00,0x0d);
get7148value(&MRD[1],&MRD[0],0x00,0x0e);
get7148value(&MRD[1],&MRD[0],0x00,0x0f);
get7148value(&MRD[1],&MRD[0],0x00,0x10);
get7148value(&MRD[1],&MRD[0],0x00,0x11);
get7148value(&MRD[1],&MRD[0],0x00,0x12);
sendbyte_uart(dat[0]);
sendbyte_uart(dat[1]);
delay(1);
};
}
复制代码
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1