4 code examples, 2 .5 .4 code examples -15 – Maxim Integrated MAXQ622 User Manual
Page 19

MAXQ612/MAXQ622 User’s Guide
Maxim Integrated
2-15
2.5.4 Code Examples
Because the MAXQ622 uses the maximum allowed program flash supported by this core, the most extreme example
of data pointer access would be the final bytes of the flash in byte mode . This can be accomplished by executing from
data memory (requiring the UPA bit to be cleared) and setting the CDA bits to map program segment P3 to the data
memory area . Code to read the final 3 bytes of the flash is shown below . This code would need to be executed from
data memory . Note that it is assumed that memory access protection, system clocking, etc ., are all configured to allow
this access .
move SC, #00B0 ; UPA=0, CDA[1:0]=11
move DPC, #0000 ; SDPS[1:0]=00, WBS0=0
move DP[0], #07FFD ;Point to 3 addresses from top of prog mem mapped intodata
move ACC, @DP[0]++ ; Move first byte to ACC to check and post increment
call CHECKB1 ; call subroutine to check first byte
move ACC, @DP[0]++ ; Move second byte to ACC to check and post increment
call CHECKB2
move ACC, @DP[0] ; Move final byte to ACC
call CHECKB3
Alternatively, the code pointer could be used for the same purpose . The advantage of this is that no code loading to
data memory is required and the UPA bit does not affect the operation . Also, the mechanism for accessing the upper
(P3) segment is a little different, using only the CPA bit instead of the CDA bits to access the upper 64KB of program
memory (since the code pointer uses the entire 64K address space for code) .
move SC, #0040 ; CPA=1
move DPC, #0000 ; CWBS=0
move CP, #0FFFD ; Point to 3 addresses from very top
move ACC, @CP++ ; Move first byte to ACC to check and post increment
call CHECKB1 ; call subroutine to check first byte
move ACC, @CP++ ; Move second byte to ACC to check and post increment
call CHECKB2
move ACC, @CP ; Move final byte to ACC
call CHECKB3
The above code could be called directly from user code in the program flash; however, each access would require two
system clock cycles to complete as opposed to the usual one cycle for data pointer access .