M306H5MG-XXXFP/MC-XXXFP/FGFP
Rev.1.20
Dec 13, 2005
page 185 of 323
REJ03B0095-0100Z
Figure 2.14.8 Example of program
;
Equations (Constant definition)
;
_CRC_ADRS
.equ
00212h
; SFR address of CRC register address control register
_CRC_DATA
.equ
00214h
; SFR address of CRC register data control register
SLICE_WORD_NUM
.equ
17
; Code data length (in nuits of word)
;
;Macro definition
;
_wait
.macro
nop
.endm
;
CRC operation routine
;
;------ Writing of code data ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
mov.w
#9010H
, _CRC_ADRS
; Set up of CRCON=1, CRCCHANGE=0, CRCLOOP=10H, Increment=ON, and CRC address=00H.
mov.w
#0000H
, _CRC_ADRS
; Initialization of CRC register address control register
mov.w
#0000H
, A0
L18:
; Branch label
cmp.w
#SLICE_WORD_NUM*2
, A0
; Comparison of the loop variable
; Initialization of a loop variable (A0)
jgeu
L20
; Go to L20 if writing code data is finished.
lde.w
_CrcCodeData[A0]
, _CRC_DATA
; Writing code data to the code data shift register.
add.w
#0002H
,A0
; Increment of the address storing code data.
jmp
L18
; Return to the head of this loop.
L20:
; Branch label
;--------- Dummy shift ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; After finishing writing 272-bit code data,
; shift a bit for dummy surely in error correction mode.
; Specifying 1-bit is set up by CRCLOOP=01H.
mov.w
#8100H
, _CRC_ADRS
; Set up of CRCON=1, CRCCHANGE=0, CRCLOOP=10H, Increment=OFF, and CRC address=00H.
_wait
; Wait
mov.w
#0000H
, _CRC_DATA
; Writing data to the code data shift register for dummy shift.
;--------- Error detection -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
; Since the address automatic increment in dummy shift (Increment=OFF), set CRC address=01H here.
; When accessing other CRC registers, the processing shown in the following two lines is necessary.
;mov.w
#9001H
, _CRC_ADRS
; Set up of CRCON=1, CRCCHANGE=0, CRCLOOP=10H, Incremet=OFF and CRC address=01H.
;
_wait
; Wait
mov.w
_CRC_DATA
, R0
; Read of CRC error detection register.
cmp.w
#0000H
, R0
; Judgement of CRC error.
jeq
L16
; In the case of R0=0, branch to L16 since CRC error has not occurred (CRC error correction is skipped).
;--------- Error correction ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
mov.w
#0D010H
, _CRC_ADRS
; Set up of CRCON=1, CRCCHANGE=1, CRCLOOP=10H, Increment=ON and CRC address=00H.
_wait
; Wait
mov.w
#0000H
, A0
; Initialization of a loop variable (A0)
L22:
; Branch label
cmp.w
#SLICE_WORD_NUB
, A0
; Comparison of the loop variable
jgeu
L24
; Go to L24 if correction of error data is finished.
lde.w
_CrcCodeData[A0]
, _CRC_DATA
; Writing code data to the code data shift register.
jsr
_waitlong
; Wait for finish of error correction.
mov.w
_CRC_DATA
, _CrcCodeData[A0]
; Read of error correction data in the address storing code data.
add.w
#0002H
, A0
; Increment of the address storing code data.
jmp
L22
; Return to the head of this loop.
L24:
; Branch label
;------- The check of error correction data--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
mov.w
#8111H
, _CRC_ADRS
; Set up of CRCON=1, CRCCHANGE=0, CRCLOOP=10H, Increment=ON and CRC address=00H
_wait
; Wait
mov.w
_CRC_DATA
, R0
; Error check after error correction. R0=000H if correction is performed.
L16:
;
; The function sample for weight for error correction
;
.align
.glb
_waitlong
_waitlong:
; Function label
rts