欢迎访问ic37.com |
会员登录 免费注册
发布采购

KMA220 参数 Datasheet PDF下载

KMA220图片预览
型号: KMA220
PDF下载: 下载PDF文件 查看货源
内容描述: 双通道可编程角度传感器 [Dual channel programmable angle sensor]
分类和应用: 传感器
文件页数/大小: 36 页 / 740 K
品牌: NXP [ NXP ]
 浏览型号KMA220的Datasheet PDF文件第19页浏览型号KMA220的Datasheet PDF文件第20页浏览型号KMA220的Datasheet PDF文件第21页浏览型号KMA220的Datasheet PDF文件第22页浏览型号KMA220的Datasheet PDF文件第24页浏览型号KMA220的Datasheet PDF文件第25页浏览型号KMA220的Datasheet PDF文件第26页浏览型号KMA220的Datasheet PDF文件第27页  
KMA220  
NXP Semiconductors  
Dual channel programmable angle sensor  
13.4.1 Software example in C  
1
#include <stdio.h.>  
2
3
// calc_crc accepts unsigned 16-bit data in data  
4
int calc_crc(int crc, unsigned int data)  
5
{
6
7
const int gpoly  
int i;  
=
0x107; // generator polynomial  
//index variable  
8
for (i = 15; i >= 0; i--)  
9
{
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
crc <<= 1;  
crc = (int) ((data  
//shift left  
(1u<<i))>>i);  
&
// XOR of with generator polynomial when MSB(9)  
if (crc 0x100) crc ^= gpoly;  
= HIGH  
&
}
return crc;  
}
int main(void)  
{
int crc, crc_res, i;  
// LSB are CRC field filled with  
unsigned int data_seq[]  
8
0
=
{0x0000, 0xFFC1, 0x0400, 0x0100,  
0x1300, 0x0000, 0x0000, 0x0000};  
// calculate checksum over all data  
crc 0xFF; // start value of crc register  
printf(“Address\tValue\n”);  
for (i 0; <= 7; i++)  
=
=
i
{
printf(“0x%1X\t0x%04X\n”, i, data_seq[i]);  
crc  
}
= calc_crc(crc, data_seq[i]);  
crc_res  
printf(“\nChecksum\n0x%02X\n”, crc_res);  
// check procedure for preceding data sequence  
crc 0xFF;  
for (i  
crc  
=
crc;  
// crc_res = 0xA9  
=
=
0;  
=
i
<= 6; i++)  
calc_crc(crc, data_seq[i]);  
// last word gets crc inserted  
crc calc_crc(crc, data_seq[i]  
printf(“\nCheck procedure for data sequence: must be 0x00 is 0x%02X.\n”, crc);  
=
crc_res);  
return 1;  
}
The checksum of this data sequence is A9h.  
KMA220  
All information provided in this document is subject to legal disclaimers.  
© NXP B.V. 2012. All rights reserved.  
Product data sheet  
Rev. 1 — 24 May 2012  
23 of 36  
 复制成功!