I am running into problems when trying to write to memory addresses on an older LPC2148 microntroller. I have tried writing to several different parts of the memory map (Section 6.4) from http://www.keil.com/dd/docs/datashts/philips/lpc2141_42_44_46_48.pdf such as on-board non-volatile, static, etc. I have also tried STMDB to the stack (0x40000000?) but the debugger sends me to the PrefetchAbort (expected if memory is non-accessible).
What am I not understanding about the memory map?
Are there global default values? I can't work with any of the ones declared in the startup.
How can I write specifically to the stack? (using STMFD or STMDB/STMIA)?
[STACK ATTEMPT] * with same startup file as below - Full Descending Stack
LDR r1, =19
LDR r2, =20
STMDB SP, { r1, r2 }
[ERROR]
*** error 65: access violation at 0x00000000 : no 'write' permission
Here is the simplest code with startup after:
[MAIN] *(ALIGNS are placed there due to the alignment error, but make no difference if they are removed)
GLOBAL user_code
AREA mycode, CODE, READONLY
user_code
LDR r1, =0x400000000
ALIGN
LDR r2, =19
ALIGN
STR r2, [r1]
ALIGN
END
[STARTUP]
; Standard definitions of Mode bits and Interrupt (I & F) flags in PSR s
Mode_USR EQU 0x10
I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled
F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled
;Defintions of User Mode Stack and Size
USR_Stack_Size EQU 0x00000100
;USR_Stack_Size EQU 0x7FFF
SRAM EQU 0x40000000
Stack_Top EQU SRAM+USR_Stack_Size
AREA RESET, CODE, Readonly
ENTRY ; The first instruction to execute follows
ARM
IMPORT user_code
VECTORS
LDR PC, Reset_Addr
LDR PC, Undef_Addr
LDR PC, SWI_Addr
LDR PC, PAbt_Addr
LDR PC, DAbt_Addr
NOP
LDR PC, IRQ_Addr
LDR PC, FIQ_Addr
Reset_Addr DCD user_code
Undef_Addr DCD UndefHandler
SWI_Addr DCD SWIHandler
PAbt_Addr DCD PAbtHandler
DAbt_Addr DCD DAbtHandler
DCD 0
IRQ_Addr DCD IRQHandler
FIQ_Addr DCD FIQHandler
SWIHandler B SWIHandler
PAbtHandler B PAbtHandler
DAbtHandler B DAbtHandler
IRQHandler B IRQHandler
FIQHandler B FIQHandler
UndefHandler B UndefHandler
; Enter User Mode with interrupts enabled
MOV r14, #Mode_USR
BIC r14,r14,#(I_Bit+F_Bit)
MSR cpsr_c, r14
;initialize the stack, full descending
LDR SP, =Stack_Top
;load start address of user code into PC
LDR PC, =user_code
;IMPORT Reset_Handler
END
[ERROR]
Non-aligned Access: ARM Instruction at 00000080H, Memory Access at 00000013H
*** error 65: access violation at 0x00000013 : no 'write' permission