-
如设置线宽为32位,CPU会把32位数据一次写入,如果外设是16位的话,如ISA网卡,就会造成高16位丢失.
例如: LDR r0, =0x10000000
LDR r1, =0x12345678
STR r1,[r0]
实际情况是 一次写入地址0x10000000的数据是 0x12345678
LDR r0, = 0xff ;DRAM刷新率refresh rate,设置要适当,否则数据丢失
STR r0, [r11, #0x200]
LDR r13, =0xc0020000 ;设置堆栈 Stack, r13 为ARM定义的堆栈指针
;Init OK
LDR r0, =receiving_msg
BL printmsg
BL dram_test ;跳转指令,执行测试DRAM
LDR r0, =startloader_cmdmsg
BL printmsg
BL Beep
LDR r0, =0x60005 ;设置波特率 38400, 8位
LDR r11, =0x80000000
STR r0, [r11, #0x4c0] ;初始化串口 UART
;Receive data and save it to buffer ;开始接收数据
LDR r12, =SaveAddr ;First 8 bytes are start address and length
;Receive address
LDR r5, =0x4 ;Read first 4 bytes
MOV r0, #0
rx_loop1
LDR r1, [r11, #0x140] ;检查系统状态寄存器System Status Register 1
TST r1, #0x00400000 ;UART1 Rx 是否为空
BNE rx_loop1 ;等待数据 Wait data
LDR r1, [r11, #0x480] ;读数据 Read data
AND r1, r1, #0xff
ORR r0, r1, r0, ROR #8
SUBS r5, r5, #1
BNE rx_loop1
MOV r0, r0, ROR #8
STR r0, [r12]
ADD r12, r12, #4