| Electronic Components Datasheet Search |
|
KMA310 Datasheet(PDF) 45 Page - NXP Semiconductors |
|
|
|||||||||||||||||||||||||||||
KMA310 Datasheet(HTML) 45 Page - NXP Semiconductors |
|
45 / 71 page ![]() NXP Semiconductors KMA310 Programmable angle sensor IC KMA310 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2019. All rights reserved. Product data sheet Rev. 3 — 27 February 2019 45 / 71 16.4.1 Software example in C++ #include "stdafx.h" #include "conio.h" unsigned int calculate_crc(unsigned int crc, unsigned int data_word) { const unsigned int gpoly = 0x107; // generator polynomial for (int i = 15; i >= 0; i--) { crc <<= 1; crc |= (int) ((data_word & (1u<<i))>>i); if (crc & 0x0100) crc ^= gpoly; } return crc; } int main(void) { unsigned int crc; // data sequence of customer area 1 unsigned int data_word[] = {0x0000, 0x0100, 0x1300, 0x1000, 0x1FFE, 0xFFFF, 0x1200, 0x0000, 0x0099, 0x0F89, 0x80FA, 0x00BE}; // seed value crc = 0xAA; printf("Seed value\n0x%02X\n\n", crc); // number of registers unsigned int N = sizeof(data_word)/sizeof(unsigned int); // 8 LSBs are reserved for checksum and must be filled with 0 data_word[N - 1] = data_word[N - 1] & 0xFF00; // calculate checksum over all addresses printf("Address\t\tValue\n"); for (unsigned int i = 0; i <= N - 1; i++) { printf("0x%02X\t\t0x%04X\n", i, data_word[i]); crc = calculate_crc(crc, data_word[i]); } printf("\nChecksum for customer area 1\n0x%02X", crc); _getch(); return 0; } The checksum of this data sequence is B3h. |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |