I have a project that works until I add in some C modules that I inherited from someone else. The startup code (sam7.s) is the default startup code supplied by KEIL for the ATMEL AT91SAM7S256 (for MDK ARM V3.22a). The problem is that when the startup code gets to the point where it's supposed to branch to the C main function, it works okay until I add in these inherited C modules. Stepping through the startup code, the only difference I can find is that the top of the stack is in a different place for the two versions of the program. For the working version it's at 0x00201F20, and the non-working version it's at 0x002022C0. For the non-working version of code, when I get to the BX ASM statement shown below, rather than going to 'main', I end up in the default SWI handler.
; Enter the C code IMPORT __main LDR R0, =__main BX R0
The __main label in the MAP file is the same value for both versions of the code, and is at 0x0010014C.
Can anyone give me some hints as to what might be causing this problem, or how to debug it...?
Thanks!