ENTER_SLEEP
;NOTE.
;1) rGSTATUS3 should have the return address after wake-up from SLEEP mode.
ldr r0,=REFRESH
ldr r1,[r0] ;r1=rREFRESH
orr r1, r1, #BIT_SELFREFRESH
str r1, [r0] ;Enable SDRAM self-refresh
;//Enable SDRAM self-refresh
mov r1,#16 ;Wait until self-refresh is issued,which may not be needed.
0
subs r1,r1,#1
bne %B0
;//Wait until self-refresh is issued,which may not be needed
ldr r1,=MISCCR ;IO register
ldr r0,[r1]
orr r0,r0,#(7<<17) ;Set SCLK0=1, SCLK1=1, SCKE=1.
str r0,[r1]
ldr r0,=CLKCON ; Enter sleep mode
str r2,[r0]
b . ;CPU will die here.
;//进入Sleep Mode,1)设置SDRAM为self-refresh
;// 2)设置MISCCR bit[17] 1:sclk0=sclk 0:sclk0=0
;// bit[18] 1:sclk1=sclk 0:sclk1=0
;// bit[19] 1:Self refresh retain enable
;// 0:Self refresh retain disable
;// When 1, After wake-up from sleep, The self-refresh will be retained.
WAKEUP_SLEEP
;Release SCLKn 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]
;//设置MISCCR
;Set memory control registers
;ldr r0,=SMRDATA
adrl r0, SMRDATA
ldr r1,=BWSCON ;BWSCON Address ;//总线宽度和等待控制寄存器
add r2, r0, #52 ;End address of SMRDATA
0
ldr r3, [r0], #4 ;数据处理后R0自加4,[R0]->R3,R0+4->R0
str r3, [r1], #4
cmp r2, r0
bne %B0
;//设置所有的memory control register,他的初始地址为BWSCON,初始化
;//数据在以SMRDATA为起始的存储区
mov r1,#256
0
subs r1,r1,#1 ;1) wait until the SelfRefresh is released.
bne %B0
;//1) wait until the SelfRefresh is released.
ldr r1,=GSTATUS3 ;GSTATUS3 has the start address just after SLEEP wake-up
ldr r0,[r1]
mov pc,r0
;//跳出Sleep Mode,进入Sleep状态前的PC
;=================================================================================
;如上所说,这里采用HANDLER宏去建立Hander***和Handle***之间的联系
LTORG ;声明文字池,因为我们用了ldr伪指令
HandlerFIQ HANDLER HandleFIQ
HandlerIRQ HANDLER HandleIRQ
HandlerUndef HANDLER HandleUndef
HandlerSWI HANDLER HandleSWI
HandlerDabort HANDLER HandleDabort
HandlerPabort HANDLER HandlePabort
;===================================================================================
;呵呵,来了来了.好戏来了,这一段程序就是用来进行第二次查表的过程了.
;如果说第一次查表是由硬件来完成的,那这一次查表就是由软件来实现的了.
;为什么要查两次表??
;没有办法,ARM把所有的中断都归纳成一个IRQ中断异常和一个FIRQ中断异常
;第一次查表主要是查出是什么异常,可我们总要知道是这个中断异常中的什么中断呀!
;没办法了,再查一次表呗!
;===================================================================================
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |