ARM学习篇 SDRAM理解(2)

BWSCON EQU 0X48000000
BANKCON0 EQU 0X48000004
BANKCON1 EQU 0X48000008
BANKCON2 EQU 0X4800000C
BANKCON3 EQU 0X48000010
BANKCON4 EQU 0X48000014
BANKCON5 EQU 0X48000018
BANKCON6 EQU 0X4800001C
BANKCON7 EQU 0X48000020
REFRESH EQU 0X48000024
BANKSIZE EQU 0X48000028
MRSRB6 EQU 0X4800002C
MRSRB7 EQU 0X48000030

;定义SDRAM相关寄存器

GPFCON EQU 0x56000050
GPFDAT EQU 0x56000054
GPFUP EQU 0x56000058

;定义GPIO端口

_ENTRY
B RESET
B .
B .
B .
B .
B .
B .;0X18
B .
RESET
LDR R0,=WTCON
LDR R1,=0
STR R1,[R0]

LDR R0,=GPFCON
LDR R1,=0X5555
STR R1,[R0]

LDR R0,=GPFUP
LDR R1,=0XFF
STR R1,[R0]

LDR R0,=GPFDAT
LDR R1,=0X5F
STR R1,[R0]


LDR R0,=BWSCON
LDR R1,=0X22011110
STR R1,[R0]

LDR R0,=BANKCON0
LDR R1,=0X00000700
STR R1,[R0]

LDR R0,=BANKCON1
LDR R1,=0X00000700
STR R1,[R0]

LDR R0,=BANKCON2
LDR R1,=0X00000700
STR R1,[R0]

LDR R0,=BANKCON3
LDR R1,=0X00000700
STR R1,[R0]

LDR R0,=BANKCON4
LDR R1,=0X00000700
STR R1,[R0]

LDR R0,=BANKCON5
LDR R1,=0X00000700
STR R1,[R0]

LDR R0,=BANKCON6
LDR R1,=0X00018005
STR R1,[R0]

LDR R0,=BANKCON7
LDR R1,=0X00018005
STR R1,[R0]


LDR R0,=REFRESH
LDR R1,=0X008C07A3
STR R1,[R0]

LDR R0,=BANKSIZE
LDR R1,=0X000000B1
STR R1,[R0]

LDR R0,=MRSRB6
LDR R1,=0X00000030
STR R1,[R0]

LDR R0,=MRSRB7
LDR R1,=0X00000030
STR R1,[R0]
;设置SDRAM相关寄存器
LDR R0,=0X0
LDR R1,=SDRAM_BASE
LDR R2,=4096

COPY_LOOP
LDR R3,[R0],#4
STR R3,[R1],#4
CMP R0,R2
BNE COPY_LOOP

;复制相关0~4kB的代码到0x30000000开始的空间


LDR R0,=0X30000000
LDR R1,=ON_SDRAM
ADD R2,R0,R1
MOV PC,R2
ON_SDRAM


LDR R0,=GPFDAT
LDR R1,=0X3F
STR R1,[R0]
;点灯
LDR R0,=0X30000000
LDR R1,=ON_SDRAM
ADD R2,R0,R1
MOV PC,R2

END

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/f4158319bb96a26f9932d7c3819eff12.html