Você está na página 1de 13

Application Note

DN[Document ID]

AS5403 CRC
Signature Calculation

ams Application Note,


[v1-03] 2015-Oct-15

Page 1
Document Feedback

AS5403 CRC Signature Calculation

Content Guide
1

General Description ............................................................................................................. 3

1.1

Signature .............................................................................................................................. 3

Signature Calculation without DLL ....................................................................................... 3

Signature Calculation with DLL ............................................................................................ 5

3.1

Signature calculation ............................................................................................................ 5

3.2

Fast Signature calculation .................................................................................................... 6

3.2.1

ams signature ....................................................................................................................... 6

3.2.2

Customer signature calculation ............................................................................................ 6

3.2.3

Final signature calculation ................................................................................................... 8

Example ............................................................................................................................... 9

4.1

DLL LabView ........................................................................................................................ 9

4.2

DLL Cplusplus ...................................................................................................................... 9

4.3

Code Example...................................................................................................................... 9

Useful Links........................................................................................................................ 10

Contact Information ............................................................................................................ 11

Copyrights & Disclaimer ..................................................................................................... 12

Revision Information .......................................................................................................... 13

ams Application Note,


[v1-03] 2015-Oct-15

Page 2
Document Feedback

AS5403 CRC Signature Calculation

General Description

This application note shows the application of signature cacluation used from DLL. The DLL can be
involved in LabView and also in other programming enviroments (C++, ).

1.1

Signature

The signature is calculated at end of line calibration by the customer and enabled with lock of the
device. The signature is used for a diagnostic check during power up.

Signature Calculation without DLL

For the Implementation without the DLL is important to prepare the EEPROM content befor the
calculation is done.
Insert 0x55AA into the line of EEPROM register address 0x1F8.

Read
EPPROM content

Read conent of registers


addresses: 0x000 to 0x1FF

Prepare
EEPROM content for
calculation

Insert 0x55AA in the line of


register address: 0x1F8

Calculate
signature out of
EEPROM content

Signature Calculation

Write
the calculated signature
in the EEPROM

Write 8-bit signature EESIGN in register


address: 0x1FF

Lock
the device (custlock)

Write 0x55AA in register


address: 0x1F8

Hardware Reset

Turn off power supply


Turn on power supply
Wait for power up (~10ms)

Figure 1: Signature calculation flow

ams Application Note,


[v1-03] 2015-Oct-15

Page 3
Document Feedback

AS5403 CRC Signature Calculation

Preparation of EEPROM content


-

Insert 0x55AA into the line where the data of the register with address 0x1F8 is

Actual content of EEPROM


(before lock the device)
0x000
xxxx xxxx xxxx xxxx
0x001
xxxx xxxx xxxx xxxx
...
...

...

Content of EEPROM prepared for


signature calculation
0x000
xxxx xxxx xxxx xxxx
0x001
xxxx xxxx xxxx xxxx
...
...

...

...

...

->
...
0x1F8
...
...
0x1FF

...
0000 0000 0000 0000
...
...
xxxx xxxx xxxx xxxx

0x55AA

+ 0101 0101 1010 1010

...
0x1F8
...
...
0x1FF

...
0101 0101 1010 1010
...
...
xxxx xxxx xxxx xxxx

Figure 2: preparing EEPROM content for calculation


The reason for data preparation is that after locking the device, in the register 0x1F8 will stand
0x55AA. For compliance between data used for calculation and real content stored in EEPROM
after end of line calibration, the data used for calculation must be prepared like it is descriped in
figure 2.

ams Application Note,


[v1-03] 2015-Oct-15

Page 4
Document Feedback

AS5403 CRC Signature Calculation

Signature Calculation with DLL

3.1

Signature calculation

The signature calculation is done at end of line calibration. After custlock the device is locked and
parameters cannot be changed anymore.
The advantage of the signature calulcation with DLL is that the content of the EEPROM data is
automatically prepared. The DLL insert 0x55AA into the line of register 0x1F8 before the calculation
is done.

Calculate signature
out of EEPROM
content

Read conent of registers


addresses: 0x000 to 0x1FF

Signature Calc
(DLL)

Read
EPPROM content

INPUT Parameters:
Input array array (uint16) = EEPROM
Data
Lenght of input array (int32) = 512dec
OUTPUT Parameters:
Signature (uint8)

Write the calculated


signature in the
EEPROM

Write 8-bit signature EESIGN in register


address: 0x1FF

Lock the device


(custlock)

Write 0x55AA in register


address: 0x1F8

Hardware Reset

Turn off power supply


Turn on power supply
Wait for power up (~10ms)

Figure 3: Signature calculation flow

ams Application Note,


[v1-03] 2015-Oct-15

Page 5
Document Feedback

AS5403 CRC Signature Calculation

3.2

Fast Signature calculation

The main advantage is that no EEPROM readout is necessary during end of line calibration.
Therefore the customer must have knowledge of the customers parameters in the EEPROM.

3.2.1 ams signature


The ams signature is calculated by ams and written by ams into the EEPROM cell (into the high
byte) with address 0x1FF .
The signature was calculated by assuming all customer related areas with zeros.
address:
0x...
...
...

content of EEPROM
xxxx xxxx xxxx xxxx
xxxx xxxx xxxx xxxx
...

address:
0x...
...
...

ams
values

Data for signature calculation


xxxx xxxx xxxx xxxx
xxxx xxxx xxxx xxxx
...

ams
values

...

...

...

...

...
...

xxxx xxxx xxxx xxxx


xxxx xxxx xxxx xxxx

...
...

0000 0000 0000 0000


0000 0000 0000 0000

...

...

customer
values

...

...

...
...
...

...
...
xxxx xxxx xxxx xxxx

customer
values

...
...
...

...
...
0000 0000 0000 0000

Asumed
zero

Signature
calulation

ams signature:

XXXX XXXX

Figure 4: ams signature calculation

3.2.2 Customer signature calculation


The data for signature calculation include all constant customer values, the modifies customer
values and instead of the ams values are assumed zeros.
address:
0x...
...
...

content of EEPROM
xxxx xxxx xxxx xxxx
xxxx xxxx xxxx xxxx
...

...

...

...
...

xxxx xxxx xxxx xxxx


xxxx xxxx xxxx xxxx

...
...
...
...

...
xxxx xxxx xxxx xxxx
xxxx xxxx xxxx xxxx
...
xxxx xxxx xxxx xxxx

Data for signature calculation


address:
0000 0000 0000 0000
0x...
0000 0000 0000 0000
...
...
...
Asumed
zeros
...
...

ams
values

customer
Values
(constant)

+ custlock
0x1F8

customer
Values
(default)

0101 0101 1010 1010

...
...
...
...
...
...

Modify
values

address:
0x...
...
...

xxxx xxxx xxxx xxxx


...
xxxx xxxx xxxx xxxx

xxxx xxxx xxxx xxxx


xxxx xxxx xxxx xxxx
...
xxxx xxxx xxxx xxxx
xxxx xxxx xxxx xxxx
...
xxxx xxxx xxxx xxxx

customer
Values
(constant)
customer
Values
(modified)

Signature
calulation

customer
Values
(modified)

customer signature:

XXXX XXXX

Figure 5: customer signature calculation

ams Application Note,


[v1-03] 2015-Oct-15

Page 6
Document Feedback

AS5403 CRC Signature Calculation

customer values

ams values

ADDRESS (HEX)

EEPROM Location Name

0x000 to 0x00A
0x00C to 0x00D
0x010 to 0x018
0x020 to 0x05E

reserved

0x080 to 0x1BF
0x1D8 to 0x1EF
0x00B

Sequencer Control

0x00E

reserved

0x00F

Magnet Lost threshold and hysteresis

0x019

Offset Bj

0x01A

Gain Bj

0x01B

Reserved

0x01C

Reserved

0x01D

Reserved

0x01E

Gain Bi

0x01F

Offset Bi

0x05F to 0x07F

Linearization Table

0x1C0 to 1CE

reserved

0x1CF

Pre-Scale Linearization

0x1D0

Post-processing Offset

0x1D1

Post-processing Gain

0x1D2

Clamp Low 1

0x1D3

Clamp High 1

0x1D4

Reserved

0x1D5

Reserved

0x1D6

Reserved

0x1D7

Reserved

0x1F0

Reserved

0x1F1

Reserved

0x1F2

Reserved

0x1F3

Reserved

0x1F4

Reserved

0x1F5

Clamp High 2 (MSBs), Clamp Low 2

0x1F6

Clamp High 2 (LSBs)

0x1F7

Angle Offset

0x1F8

Customer LOCK (lock= 0x55AA)

0x1F9

Output configuration and PWM frequency

0x1FA

DSW driver configuration

0x1FB

DSW settings

0x1FC

Customer ID

0x1FD

Customer ID

0x1FE

Customer ID

0x1FF

EEPROM Signature + Customer ID

Figure 6: EEPROM values partition

ams Application Note,


[v1-03] 2015-Oct-15

Page 7
Document Feedback

AS5403 CRC Signature Calculation

3.2.3 Final signature calculation

Modify
values

Modify
values

On customer side the EEPROM must not be read from every device. Once the EEPROM content is
known. The customer just need the ams signature, calculate the customer signature and XOR the
singatures to the final signature.
ams signature:
XXXX XXXX

final signature:

customer signature:
XXXX XXXX

XXXX XXXX

Figure 7: final signature calculation

The final steps are


-

WRITE the final signature into the EEPROM


[8-bit signature EESIGN in register address: 0x1FF]

LOCK

the device (custlock)


[Write 0x55AA in the register address: 0x1F8]

Hardware RESET
[Turn off power supply]
[Turn on power supply]
[Wait for power up (~10ms)]

ams Application Note,


[v1-03] 2015-Oct-15

Page 8
Document Feedback

AS5403 CRC Signature Calculation

4.1

Example

DLL LabView

The example shows an implementation in Labview.

4.2

DLL Cplusplus

Example of header for cplusplus implementation.


AS5403Signature(uint16_t EEPROMDATA[], int32_t len, uint8_t *signature0x1FFHighByte);

4.3

Code Example

The example shows a CRC calculation in C.


The array content is 1023byte tall and the numer 29(dec) is representation of the polynomial in normal
way.
Unsigned int signature (unsigned int * content)
{
unsigned int misr,misr_shift,misr_xor,misr_msb;
misr = 0;
for (int i=0; i<1023; i++) {
misr_shift = (misr<<1);
misr_xor = (misr_shift ^ content[i])%256;
misr_msb = misr/(128);
if (misr_msb == 0)
misr = misr_xor;
else
misr = (misr_xor ^ 29)%256;
}
return misr;
}

ams Application Note,


[v1-03] 2015-Oct-15

Page 9
Document Feedback

AS5403 CRC Signature Calculation

Useful Links

Wikipedia:
https://en.wikipedia.org/wiki/Cyclic_redundancy_check

ams Application Note,


[v1-03] 2015-Oct-15

Page 10
Document Feedback

AS5403 CRC Signature Calculation

Contact Information

Buy our products or get free samples online at:


www.ams.com/ICdirect
Technical Support is available at:
www.ams.com/Technical-Support
Provide feedback about this document at:
www.ams.com/Document-Feedback
For further information and requests, e-mail us at:
ams_sales@ams.com
For sales offices, distributors and representatives, please visit:
www.ams.com/contact

Headquarters
ams AG
Tobelbaderstrasse 30
8141 Unterpremstaetten
Austria, Europe
Tel: +43 (0) 3136 500 0
Website: www.ams.com

ams Application Note,


[v1-03] 2015-Oct-15

Page 11
Document Feedback

AS5403 CRC Signature Calculation

Copyrights & Disclaimer

Copyright ams AG, Tobelbader Strasse 30, 8141 Unterpremstaetten, Austria-Europe. Trademarks
Registered. All rights reserved. The material herein may not be reproduced, adapted, merged,
translated, stored, or used without the prior written consent of the copyright owner.
Information in this document is believed to be accurate and reliable. However, ams AG does not
give any representations or warranties, expressed or implied, as to the accuracy or completeness of
such information and shall have no liability for the consequences of use of such information.
Applications that are described herein are for illustrative purposes only. ams AG makes no
representation or warranty that such applications will be appropriate for the specified use without
further testing or modification. ams AG takes no responsibility for the design, operation and testing
of the applications and end-products as well as assistance with the applications or end-product
designs when using ams AG products. ams AG is not liable for the suitability and fit of ams AG
products in applications and end-products planned.
ams AG shall not be liable to recipient or any third party for any damages, including but not limited
to personal injury, property damage, loss of profits, loss of use, interruption of business or indirect,
special, incidental or consequential damages, of any kind, in connection with or arising out of the
furnishing, performance or use of the technical data or applications described herein. No obligation
or liability to recipient or any third party shall arise or flow out of ams AG rendering of technical or
other services.
ams AG reserves the right to change information in this document at any time and without notice.

ams Application Note,


[v1-03] 2015-Oct-15

Page 12
Document Feedback

AS5403 CRC Signature Calculation

Revision Information
Changes from previous version to current revision 1-03 (2015-Oct-15)

Page

Fast signature calculation was added


Initial version 1-00
Note: Page numbers for the previous version may differ from page numbers in the current revision.
Correction of typographical errors is not explicitly mentioned.

ams Application Note,


[v1-03] 2015-Oct-15

Page 13
Document Feedback