KMA199 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2011. All rights reserved.
Product data sheet Rev. 2 — 7 December 2011 22 of 36
NXP Semiconductors
KMA199
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 const int gpoly = 0x107; // generator polynomial
7 int i; //index variable
8 for (i = 15; i >= 0; i--)
9{
10 crc <<= 1; //shift left
11 crc = (int) ((data & (1u<<i))>>i);
12 // XOR of with generator polynomial when MSB(9) = HIGH
13 if (crc & 0x100) crc ^= gpoly;
14 }
15 return crc;
16 }
17 int main(void)
18 {
19 int crc, crc_res, i;
20 // 8 LSB are CRC field filled with 0
21 unsigned int data_seq[] = {0x1111, 0x2222, 0x3333, 0x4444,
22 0x5555, 0x6666, 0x7777, 0x8888,
23 0x9999, 0xAAAA, 0xBBBB, 0xCCCC,
24 0xDDDD, 0xEEEE, 0xFFFF, 0x4200};
25 // calculate checksum over all data
26 crc = 0xFF; // start value of crc register
27 printf(“Address\tValue\n”);
28 for (i = 0; i <= 15; i++)
29 {
30 printf(“0x%1X\t0x%04X\n”, i, data_seq[i]);
31 crc = calc_crc(crc, data_seq[i]);
32 }
33 crc_res = crc; // crc_res = 0x6F
34 printf(“\nChecksum\n0x%02X\n”, crc_res);
35 // check procedure for above data sequence
36 crc = 0xFF;
37 for (i = 0; i <= 14; i++)
38 crc = calc_crc(crc, data_seq[i]);
39 // last word gets crc inserted
40 crc = calc_crc(crc, data_seq[i] crc_res);
41 printf(“\nCheck procedure for data sequence: must be 0x00 is 0x%02X.\n”,crc);
42 return 1;
43 }
The checksum of this data sequence is 6Fh.
KMA199 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2011. All rights reserved.
Product data sheet Rev. 2 — 7 December 2011 23 of 36
NXP Semiconductors
KMA199
Programmable angle sensor
13.5 Registers
13.5.1 Command registers
To enter the command mode, the signature given in Table 16 must be written using the
OWI into the specific register. This must be done as described in Section 13.3.3
, with a
write command, followed by the signature, but after a power-on reset and not later than
t
cmd(ent)
.
Table 16. Command registers
Command
write/read
Register Bit Access Field Description
82h/83h CTRL1 15 R IN_DIAG_MODE shows if there is a diagnostic condition present;
this bit is not affected by the setting of the register
field FORCE_DIAG_OFF
14 R/W FORCE_DIAG_OFF force diagnostic mode off; default: 0b
13 - - reserved
12 R LOW_VOLTAGE_DET low voltage condition detected
11 R/W EEP_CP_CLOCK_EN charge pump clock on (must be set after setting
EEPROM write enable signal for writing to
EEPROM); default: 0b
10 and 9 - - reserved
8 R EEP_ERR_CORRECT EDC: EEPROM error has been corrected; updated
every EEPROM readout and remains set once set
7 R EEP_UNCORR_ERR EDC: EEPROM uncorrectable error has been
detected; updated every EEPROM readout and
remains set once set
6 R MAGNET_LOSS_DET magnet-loss detected; bit remains set even if the
condition disappears; for this detection which leads
to diagnostic mode, the magnet-loss detection
must be enabled
5 - - reserved
4 R CRC_BAD CRC check has failed (checked during start-up)
3to0 - - reserved
94h/- SIGNATURE 15 to 0 W SIGNATURE write signature 9BA4h within t
cmd(ent)
to enter
command mode; see Section 13.3.3
for more
details
96h/97h TESTCTRL0 15 to 12 - - reserved
11 W EEP_WRITE_EN EEPROM write enable signal (must be set before
writing to EEPROM)
0605h — disabled (default)
0E05h — enabled
10 to 0 - - reserved
KMA199 All information provided in this document is subject to legal disclaimers. © NXP B.V. 2011. All rights reserved.
Product data sheet Rev. 2 — 7 December 2011 24 of 36
NXP Semiconductors
KMA199
Programmable angle sensor
13.5.2 EEPROM registers
The device includes several internal registers which are used for customization and
identification.
The initial signature allows read access to all areas but only write access to customer
registers. Write accesses to reserved areas are ignored. Since these registers are
implemented as EEPROM cells, writing to the registers needs a specific time t
prog
after
each write access to complete.
As there is no check for the programming time, the user must make sure no other
accesses to the EEPROM are made during the programming cycle. The EEPROM must
not be addressed during the time t
prog
.
Note: Before data can be stored in the EEPROM, the internal charge pump has to be
switched on for the programming duration by setting register CTRL1, bit 11
EEP_CP_CLOCK_EN and register TESTCTRL0, bit 11 EEP_WRITE_EN. All register
addresses have to be read out for calculating the checksum. However, some register
addresses are reserved for calibration.
Table 17. EEPROM registers
Address Command
write/read
Register Bit Description Default
MSB/LSB
0h -/01h reserved - addresses are reserved for calibration purposes
Note: These addresses have to be read out for
calculating the checksum.
[1]
1h -/03h
2h -/05h
3h -/07h
4h -/09h
5h -/0Bh
6h -/0Dh
7h 0Eh/0Fh ZERO_ANGLE 15 to 0 mechanical zero degree position 00h/00h
8h 10h/11h MAGNET_LOSS 15 to 0 magnet-loss detection
0000h — disabled
004Fh — enabled
00h/00h
9h 12h/13h ANG_RNG_MULT_LSB 15 to 3 least significant bits of the angular range
multiplicator
20h/00h
2 to 0 undefined
[2]
Ah 14h/15h CLAMP_LO 15 to 13 undefined
[2]
01h/00h
12 to 0 lower clamping level output voltage
Bh 16h/17h CLAMP_HI 15 to 13 undefined
[2]
12h/FFh
12 to 0 upper clamping level output voltage
Ch 18h/19h ID_LO 15 to 0 lower 16 bits of identification code 00h/00h
Dh 1Ah/1Bh ID_HI 15 to 0 upper 16 bits of identification code 00h/00h
Eh 1Ch/1Dh CLAMP_SW_ANGLE 15 to 6 when angle is bigger than CLAMP_SW_ANGLE
the output switches to CLAMP_LO for a positive
slope
FFh/C1h
ANG_RNG_MULT_MSB 5 to 0 most significant bits of the angular range
multiplicator

KMA199,115

Mfr. #:
Manufacturer:
NXP Semiconductors
Description:
Magnetic Sensors Board Mount Hall Effect / Magnetic Sensors Programble Angle Sensor 5V 5mA-10mA
Lifecycle:
New from this manufacturer.
Delivery:
DHL FedEx Ups TNT EMS
Payment:
T/T Paypal Visa MoneyGram Western Union

Products related to this Datasheet