//AD7147寄存器设置,SETUP_7148_a(高位地址,低位地址,高位配置数据,低位配置数据)
//第一步设置:配置寄存器二,7个阶段即实现cin0:7的配置
//Stage0 - CIN0--CIN11(+)
SETUP_7148_a(0x00,0x80,0x2A,0xAA);
SETUP_7148_a(0x00,0x81,0x3A,0xAA);
SETUP_7148_a(0x00,0x82,0x01,0x00);
SETUP_7148_a(0x00,0x83,0x26,0x26);
SETUP_7148_a(0x00,0x84,0x20,0x00);
SETUP_7148_a(0x00,0x85,0x20,0x00);
SETUP_7148_a(0x00,0x86,0x20,0x00);
SETUP_7148_a(0x00,0x87,0x20,0x00);
//Stage1 - CIN1(+)
SETUP_7148_a(0x00,0x88,0x3F,0xFB);
SETUP_7148_a(0x00,0x89,0x3F,0xFF);
SETUP_7148_a(0x00,0x8A,0x01,0x00);
SETUP_7148_a(0x00,0x8B,0x26,0x26);
SETUP_7148_a(0x00,0x8C,0x20,0x00);
SETUP_7148_a(0x00,0x8D,0x20,0x00);
SETUP_7148_a(0x00,0x8E,0x20,0x00);
SETUP_7148_a(0x00,0x8F,0x20,0x00);
//Stage2 - CIN2(+)
SETUP_7148_a(0x00,0x90,0x3F,0xEF);
SETUP_7148_a(0x00,0x91,0x1F,0xFF);
SETUP_7148_a(0x00,0x92,0x01,0x00);
SETUP_7148_a(0x00,0x93,0x26,0x26);
SETUP_7148_a(0x00,0x94,0x20,0x00);
SETUP_7148_a(0x00,0x95,0x20,0x00);
SETUP_7148_a(0x00,0x96,0x20,0x00);
SETUP_7148_a(0x00,0x97,0x20,0x00);
//Stage3 - CIN3(+)
SETUP_7148_a(0x00,0x98,0x3F,0xBF);
SETUP_7148_a(0x00,0x99,0x1F,0xFF);
SETUP_7148_a(0x00,0x9A,0x01,0x00);
SETUP_7148_a(0x00,0x9B,0x26,0x26);
SETUP_7148_a(0x00,0x9C,0x20,0x00);
SETUP_7148_a(0x00,0x9D,0x20,0x00);
SETUP_7148_a(0x00,0x9E,0x20,0x00);
SETUP_7148_a(0x00,0x9F,0x20,0x00);
//Stage4 - CIN4(+)
SETUP_7148_a(0x00,0xA0,0x3E,0xFF);
SETUP_7148_a(0x00,0xA1,0x1F,0xFF);
SETUP_7148_a(0x00,0xA2,0x01,0x00);
SETUP_7148_a(0x00,0xA3,0x26,0x26);
SETUP_7148_a(0x00,0xA4,0x20,0x00);
SETUP_7148_a(0x00,0xA5,0x20,0x00);
SETUP_7148_a(0x00,0xA6,0x20,0x00);
SETUP_7148_a(0x00,0xA7,0x20,0x00);
//Stage5 - CIN5(+)
SETUP_7148_a(0x00,0xA8,0x3B,0xFF);
SETUP_7148_a(0x00,0xA9,0x1F,0xFF);
SETUP_7148_a(0x00,0xAA,0x01,0x00);
SETUP_7148_a(0x00,0xAB,0x26,0x26);
SETUP_7148_a(0x00,0xAC,0x20,0x00);
SETUP_7148_a(0x00,0xAD,0x20,0x00);
SETUP_7148_a(0x00,0xAE,0x20,0x00);
SETUP_7148_a(0x00,0xAF,0x20,0x00);
//Stage6 - CIN6(+)
SETUP_7148_a(0x00,0xb0,0x2F,0xFF);
SETUP_7148_a(0x00,0xb1,0x1F,0xFF);
SETUP_7148_a(0x00,0xb2,0x01,0x00);
SETUP_7148_a(0x00,0xb3,0x26,0x26);
SETUP_7148_a(0x00,0xb4,0x20,0x00);
SETUP_7148_a(0x00,0xb5,0x20,0x00);
SETUP_7148_a(0x00,0xb6,0x20,0x00);
SETUP_7148_a(0x00,0xb7,0x20,0x00);
//Stage7 - CIN7(+)
SETUP_7148_a(0x00,0xb8,0x3F,0xFF);
SETUP_7148_a(0x00,0xb9,0x1F,0xFE);
SETUP_7148_a(0x00,0xbA,0x01,0x00);
SETUP_7148_a(0x00,0xbB,0x26,0x26);
SETUP_7148_a(0x00,0xbC,0x20,0x00);
SETUP_7148_a(0x00,0xbD,0x20,0x00);
SETUP_7148_a(0x00,0xbE,0x20,0x00);
SETUP_7148_a(0x00,0xbF,0x20,0x00);
//Stage8 - CIN8(+)
SETUP_7148_a(0x00,0xC0,0x3F,0xFF);
SETUP_7148_a(0x00,0xC1,0x1F,0xFB);
SETUP_7148_a(0x00,0xC2,0x01,0x00);
SETUP_7148_a(0x00,0xC3,0x26,0x26);
SETUP_7148_a(0x00,0xC4,0x20,0x00);
SETUP_7148_a(0x00,0xC5,0x20,0x00);
SETUP_7148_a(0x00,0xC6,0x20,0x00);
SETUP_7148_a(0x00,0xC7,0x20,0x00);
//Stage9 -CIN9(+)
SETUP_7148_a(0x00,0xC8,0x3F,0xFF);
SETUP_7148_a(0x00,0xC9,0x1F,0xEF);
SETUP_7148_a(0x00,0xCa,0x01,0x00);
SETUP_7148_a(0x00,0xCb,0x26,0x26);
SETUP_7148_a(0x00,0xCc,0x20,0x00);
SETUP_7148_a(0x00,0xCd,0x20,0x00);
SETUP_7148_a(0x00,0xCe,0x20,0x00);
SETUP_7148_a(0x00,0xCf,0x20,0x00);
//Stage10 -CIN10(+)
SETUP_7148_a(0x00,0xD0,0x3F,0xFF);
SETUP_7148_a(0x00,0xD1,0x1E,0xBF);
SETUP_7148_a(0x00,0xD2,0x01,0x00);
SETUP_7148_a(0x00,0xD3,0x26,0x26);
SETUP_7148_a(0x00,0xD4,0x20,0x00);
SETUP_7148_a(0x00,0xD5,0x20,0x00);
SETUP_7148_a(0x00,0xD6,0x20,0x00);
SETUP_7148_a(0x00,0xD7,0x20,0x00);
//Stage11 -CIN11(+)
SETUP_7148_a(0x00,0xD8,0x3F,0xFF);
SETUP_7148_a(0x00,0xD9,0x1E,0xFF);
SETUP_7148_a(0x00,0xDa,0x01,0x00);
SETUP_7148_a(0x00,0xDb,0x26,0x26);
SETUP_7148_a(0x00,0xDc,0x20,0x00);
SETUP_7148_a(0x00,0xDd,0x20,0x00);
SETUP_7148_a(0x00,0xDe,0x20,0x00);
SETUP_7148_a(0x00,0xDf,0x20,0x00);
//第二步设置:配置寄存器1
// SETUP_7148_a(0x00,0x00,0x02,0xB2);
SETUP_7148_a(0x00,0x00,0x01,0x12);
get7148value(&MRD[1],&MRD[0],0x00,0x0A);
SETUP_7148_a(0x00,0x02,0x32,0x33);
SETUP_7148_a(0x00,0x03,0x08,0x19);
// SETUP_7148_a(0x00,0x02,0x32,0x3B);
// SETUP_7148_a(0x00,0x03,0x0A,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,0x01);
// SETUP_7148_a(0x00,0x07,0x00,0x00);
//第三步设置
SETUP_7148_a(0x00,0x01,0x0f,0xff);
get7148value(&MRD[1],&MRD[0],0x00,0x0A);
get7148value(&MRD[1],&MRD[0],0x00,0x17);
#获取STAGE0--STAGE11数据
- while(1)
- {
- //n=0;
- //dat[0] =0;
- //dat[1] =0;
- //发送一帧数据,两个帧头,八个传感器数据,两个帧尾
- sendbyte_uart(0xa1); //帧头‘a1’
- sendbyte_uart(0xa5); //帧头‘a2’
- //getAD7148value:主机向AD7148发送地址数据--从寄存器3读取数据存入MRD数组
- //函数原型void get7148value(unsigned char *ph,unsigned char *pl,unsigned char addrh,unsigned char addrl)
- 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);
- get7148value(&MRD[1],&MRD[0],0x00,0x13);
- get7148value(&MRD[1],&MRD[0],0x00,0x14);
- get7148value(&MRD[1],&MRD[0],0x00,0x15);
- get7148value(&MRD[1],&MRD[0],0x00,0x16);
- //sendbyte_uart(dat[0]);
- //sendbyte_uart(dat[1]);
- delay(1);
- }
更多回帖