Preliminary
SN8P1702A/SN8P1703A
8-bit micro-controller build-in 12-bit ADC
CHECKSUM CALCULATION
The ROM addresses 0004H~0007H and last address are reserved area. User should avoid these addresses
(0004H~0007H and last address) when calculate the Checksum value.
ꢁ
Example:
The demo program shows how to avoid 0004H~0007H when calculated Checksum from 00H to the end of
user’s code
MOV
A,#END_USER_CODE$L
B0MOV
MOV
END_ADDR1,A
A,#END_USER_CODE$M
; save low end address to end_addr1
B0MOV
CLR
CLR
END_ADDR2,A
Y
Z
; Save middle end address to end_addr2
; Set Y to 00H
; Set Z to 00H
@@:
CALL
MOVC
B0BSET
ADD
YZ_CHECK
; Call function of check yz value
;
; Clear C flag
; Add A to Data1
FC
DATA1,A
A,R
MOV
ADC
JMP
DATA2,A
END_CHECK
; Add R to Data2
; Check if the YZ address = the end of code
AAA:
INCMS
JMP
JMP
Z
@B
Y_ADD_1
;Z=Z+1
; If Z! = 00H calculate to next address
; If Z=00H increase Y
END_CHECK:
MOV
A,END_ADDR1
CMPRS
JMP
A,Z
AAA
; Check if Z = low end address
; If Not jump to checksum calculate
MOV
CMPRS
JMP
A,END_ADDR2
A,Y
AAA
; If Yes, check if Y = middle end address
; If Not jump to checksum calculate
; If Yes checksum calculated is done.
;check if YZ=0004H
JMP
CHECKSUM_END
YZ_CHECK:
MOV
CMPRS
RET
A,#04H
A,Z
;check if Z=04H
;if Not return to checksum calculate
MOV
CMPRS
RET
A,#00H
A,Y
;if Yes, check if Y=00H
;if Not return to checksum calculate
;if Yes, increase 4 to Z
INCMS
INCMS
INCMS
INCMS
RET
Z
Z
Z
Z
;set YZ=0008H then return
;increase Y
Y_ADD_1:
INCMS
NOP
Y
JMP
@B
;jump to checksum calculate
CHECKSUM_END:
END_USER_CODE:
……….
……….
;Label of program end
SONiX TECHNOLOGY CO., LTD
Page 20
Revision 0.5