bne ENTER_SLEEP ;C=0,即TST结果非0,bit[3]=1
;//进入PWDN后如果不是sleep则进入stop
;//进入Stop mode
ENTER_STOP
ldr r0,=REFRESH ;0x48000024 DRAM/SDRAM refresh config
ldr r3,[r0] ;r3=rREFRESH
mov r1, r3
orr r1, r1, #BIT_SELFREFRESH ;Enable SDRAM self-refresh
str r1, [r0] ;Enable SDRAM self-refresh
;//Enable SDRAM self-refresh
mov r1,#16 ;wait until self-refresh is issued. may not be needed.
0 subs r1,r1,#1
bne %B0
;//wait 16 fclks for self-refresh
ldr r0,=CLKCON ;enter STOP mode.
str r2,[r0]
;//??????????????
mov r1,#32
0 subs r1,r1,#1 ;1) wait until the STOP mode is in effect.
bne %B0 ;2) Or wait here until the CPU&Peripherals will be turned-off
;Entering SLEEP mode, only the reset by wake-up is available.
ldr r0,=REFRESH ;exit from SDRAM self refresh mode.
str r3,[r0]
MOV_PC_LR ;back to main process
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
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
;//异常中断宏调用
LTORG
HandlerFIQ HANDLER HandleFIQ
HandlerIRQ HANDLER HandleIRQ
HandlerUndef HANDLER HandleUndef
HandlerSWI HANDLER HandleSWI
HandlerDabort HANDLER HandleDabort
HandlerPabort HANDLER HandlePabort
IsrIRQ
sub sp,sp,#4 ;reserved for PC
stmfd sp!,{r8-r9}
ldr r9,=INTOFFSET ;地址为0x4a000014的空间存着中断的偏移
ldr r9,[r9] ;I_ISR
ldr r8,=HandleEINT0
add r8,r8,r9,lsl #2
ldr r8,[r8]
str r8,[sp,#8]
ldmfd sp!,{r8-r9,pc}
;//外部中断号判断,通过中断服务程序入口地址存储器的地址偏移确定
;//PC=[HandleEINT0+][INTOFFSET]]
;=======
; ENTRY
;扳子上电和复位后 程序开始从位于0x0执行b ResetHandler 程序从跳转到这里执行
;板子上电复位后 执行几个步骤这里通过标号在注释中加1,2,3....标示 标号表示执行顺序
;1.禁止看门狗 屏蔽所有中断
;=======
ResetHandler
;//1.禁止看门狗 屏蔽所有中断
ldr r0,=WTCON ;watch dog disable
ldr r1,=0x0
str r1,[r0]
ldr r0,=INTMSK
ldr r1,=0xffffffff ;all interrupt disable
str r1,[r0]
ldr r0,=INTSUBMSK
ldr r1,=0x3ff ;all sub interrupt disable
str r1,[r0]
[ {FALSE}
;//rGPFDAT = (rGPFDAT & ~(0xf<4)) | ((~data & 0xf)<4);
;//Led_Display
ldr r0,=GPFCON ;//F-IO In/Out config 10 10 10 10 00 00 00 00
ldr r1,=0x5500 ;//00 = Input 01 = Output
str r1,][r0] ;//10 = EINT[0] 11 = Reserved
ldr r0,=GPFDAT ;//F-IO data register
ldr r1,=0x10
str r1,[r0]
]
|