Datasheet
Checking Integrity of SegmentA
www.ti.com
; The corrected value is available in ADC_COR
MOV.W &ADC12MEM0,R10 ; move result to R10
RLA.W R10 ; R10 * 2
MOV.W R10,&MPY ; unsigned multiply OP1
MOV.W CAL_ADC_GAIN_FACTOR(R9),&OP2
; calibration value OP2
MOV.W &RESHI,&ADC_COR ; use upper 16-bit MPY
ADD.W CAL_ADC_OFFSET(R9),&ADC_COR
; add offset correction
24.3 Checking Integrity of SegmentA
The 64-byte SegmentA contains a 2-byte checksum of the data stored at 0x10C2 up to 0x10FF at
addresses 0x10C0 and 0x10C1. The checksum is a bit-wise XOR of 31 words stored in the twos-
complement data format.
A code example to calculate the checksum follows.
; Checking the SegmentA integrity by calculating the 2's
; complement of the 31 words at 0x10C2 - 0x10FE.
; It is assumed that the SegmentA Start Address is stored
; in R10. R11 is initialized to 0x00.
; The label TLV_CHKSUM is set to 0x10C0.
ADD.W #2,R10 ; Skip the checksum
LP0 XOR.W @R10+,R11 ; Add a word to checksum
CMP.W #0x10FF,R10 ; Last word included?
JN LP0 ; No, add more data
ADD.W &TLV_CHKSUM,R11 ; Add checksum
JNZ CSNOK ; Checksum not ok
... ; Use SegmentA data
CSNOK ... ; Do not use SegmentA Data
24.4 Parsing TLV Structure of Segment A
Example code to analyze SegmentA follows.
; It is assumed that the SegmentA start address
; is stored in R10.
LP1 ADD.W #2,R10 ; Skip two bytes
CMP.W #0x10FF,R10 ; SegmentA end reached?
JGE DONE ; Yes, done
CMP.B #TAG_EMPTY,0(R10) ; TAG_EMPTY?
JNZ T1 ; No, continue
JMP LP2 ; Yes, done with TAG_EMPTY
T1 CMP.B #TAG_ADC12_1,0(R10) ; TAG_ADC12_1?
JNZ T2 ; No, continue
... ; Yes, found TAG_ADC12_1
JMP LP2 ; Done with TAG_ADC12_1
T2 CMP.B #DCO_30,0(R10) ; TAG_DCO_30?
JNZ T3 ; No, continue
CLR.B &DCOCTL ; Select lowest DCOx
MOV.B 7(R10),&BCSCTL1 ; Yes, use e.g. 8MHz data and
MOV.B 6(R10),&DCOCTL ; set DCOx and MODx
JMP LP2 ; Done with TAG_DCO_30
T3 ... ; Test for "next tag"
... ;
JMP LP2 ; Done with "next tag"
586
TLV Structure SLAU144J–December 2004–Revised July 2013
Submit Documentation Feedback
Copyright © 2004–2013, Texas Instruments Incorporated