Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

RE: [lpc2000] Non-aligned access?

2005-11-08 by Dan Beadle

The basic cause of this error is having an program fetch that is not
aligned on a multiple of 4. (the 241H in your example).

So how did you do this?  This can happen by corrupting the stack or
altering the stack pointer.  (Set the SP to 4000 0241 and do a return
will generate the error).  The other way is to walk on the stack and
alter a return address to point to a non-multiple of 4 and do a return.
Yet another way is attempt to do a word or half word load (set rx = 4000
0241, followed by a ldr rm,[rx]).  You could do this from assembler, but
you can also do it with pointers. Eg.  Int *pword; pword = 0x40000241; y
= *pword does a fetch from a non-aligned address...)

So many opportunities!

Dan


-----Original Message-----
From: lpc2000@yahoogroups.com [mailto:lpc2000@yahoogroups.com] On Behalf
Of Tom Walsh
Sent: Monday, November 07, 2005 5:41 PM
To: lpc2000@yahoogroups.com
Subject: Re: [lpc2000] Non-aligned access?

ee_gary wrote:

>Hello,
>
>I'm having a problem where my code goes into the bushes after ~10
>seconds.  Running it in the simulator results in a "Non-aligned
>Access" error, ARM Instruction at 00000200H, Memory Access at
>40000241H.  Any idea what that means?  Simple code, just an interrupt
>driven timer and interrupt driven SPI...
>
>  
>
You can run into this when mixing Thumb with ARM code. When interrupt 
routines are entered, the processor is in ARM mode, either write your 
handlers in ARM or switch to THUMB mode, process the interrupt, then 
exit THUMB mode and return from interrupt.

FWIW, Thumb, and thumb-internetworking, is too much trouble to deal 
with, I run strictly ARM mode.

TomW



-- 
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------------------------------------------





 
Yahoo! Groups Links

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.