mayhave not to be changed.
;void EnterPWDN(int CLKCON);
EnterPWDN
movr2,r0 ;r2=rCLKCON
tstr0,#0x8 ;SLEEP mode
bneENTER_SLEEP
ENTER_STOP
ldrr0,=REFRESH
ldrr3,[r0] ;r3=rREFRESH
movr1, r3
orrr1, r1, #BIT_SELFREFRESH
strr1, [r0] ;Enable SDRAMself-refresh
movr1,#16 ;wait untilself-refresh is issued. may not be needed.
0 subsr1,r1,#1
bne%B0
ldrr0,=CLKCON ;enter STOP mode.
strr2,[r0]
movr1,#32
0 subsr1,r1,#1 ;1) wait until the STOP mode isin effect.
bne%B0 ;2) Or wait here until theCPU&Peripherals will be turned-off
; Entering SLEEP mode, only the reset bywake-up is available.
ldrr0,=REFRESH ;exit from SDRAM self refresh mode.
strr3,[r0]
MOV_PC_LR
ENTER_SLEEP
;NOTE.
;1)rGSTATUS3 should have the return address after wake-up from SLEEP mode.
ldrr0,=REFRESH
ldrr1,[r0] ;r1=rREFRESH
orrr1, r1, #BIT_SELFREFRESH
strr1, [r0] ;Enable SDRAMself-refresh
movr1,#16 ;Wait untilself-refresh is issued,which may not be needed.
0 subsr1,r1,#1
bne%B0
ldr r1,=MISCCR
ldr r0,[r1]
orr r0,r0,#(7<<17) ;Set SCLK0=0, SCLK1=0, SCKE=0.
str r0,[r1]
ldrr0,=CLKCON ; Enter sleep mode
strr2,[r0]
b. ;CPU will die here.
WAKEUP_SLEEP
;ReleaseSCLKn after wake-up from the SLEEP mode.
ldr r1,=MISCCR
ldr r0,[r1]
bic r0,r0,#(7<<17) ;SCLK0:0->SCLK, SCLK1:0->SCLK,SCKE:0->=SCKE.
str r0,[r1]
;Setmemory control registers
ldr r0,=SMRDATA ;be careful!
ldr r1,=BWSCON ;BWSCONAddress
add r2, r0, #52 ;Endaddress of SMRDATA
0
ldr r3, [r0], #4
str r3, [r1], #4
cmp r2, r0
bne %B0
movr1,#256
0 subsr1,r1,#1 ;1) wait until the SelfRefreshis released.
bne%B0
ldrr1,=GSTATUS3 ;GSTATUS3 has the startaddress just after SLEEP wake-up
ldrr0,[r1]
movpc,r0
;=====================================================================
; Clock division test
; Assemble code, because VSYNC time is veryshort
;=====================================================================
EXPORTCLKDIV124
EXPORTCLKDIV144
CLKDIV124
ldr r0, = CLKDIVN
ldr r1, = 0x3 ;0x3 = 1:2:4
str r1, [r0]
; waituntil clock is stable
nop
nop
nop
nop
nop
ldr r0, = REFRESH
ldr r1, [r0]
bic r1, r1, #0xff
bic r1, r1, #(0x7<<8)
orr r1, r1, #0x470 ; REFCNT135
str r1, [r0]
nop
nop
nop
nop
nop
mov pc, lr
CLKDIV144
ldr r0, = CLKDIVN
ldr r1, = 0x4 ;0x4 = 1:4:4
str r1, [r0]
; waituntil clock is stable
nop
nop
nop
nop
nop
ldr r0, = REFRESH
ldr r1, [r0]
bic r1, r1, #0xff
bic r1, r1, #(0x7<<8)
orr r1, r1, #0x630 ; REFCNT675 - 1520
str r1, [r0]
nop
nop
nop
nop
nop
mov pc, lr
ALIGN
;定义数据段
;^ 标志等价于MAP伪指令
;MAP用于定