Greetings: Here is an odd one that I hope someone can point out the obvious thing I am doing wrong. In the accompanying extremely simplified source code, compiled with uVision3 V3.12a, I am just calling a function with six parameters. Nothing earth shattering about that, and running this code under the simulator it works fine. Prior to the function call the first four parameters are loaded into registers and the fifth and sixth are pushed on the sack, as other forum discussions state that it should. The function returns the sum of the parameters, as expected. When I run this on the target environment, however, the processor pushes zeros onto the stack instead of the fifth and sixth parameter and, of course, the return value is wrong.
//* Main.c ********************************** #include <LPC22XX.H> unsigned char Param6Test ( char, char, char, char, char, char ); //******************************************* void main ( void ) { char Param1; char Param2; char Param3; char Param4; char Param5; char Param6; char RetVal; Param1 = 1; Param2 = 2; Param3 = 3; Param4 = 4; Param5 = 5; Param6 = 6; while ( 1 ) { RetVal = Param6Test ( Param1, Param2, Param3, Param4, Param5, Param6 ); if ( RetVal == 1 ) Param1++; } } //******************************************* char Param6Test ( char x1, char x2, char x3, char x4, char x5, char x6 ) { char charRetval; charRetval = x1; charRetval = charRetval + x2; charRetval = charRetval + x3; charRetval = charRetval + x4; charRetval = charRetval + x5; charRetval = charRetval + x6; return ( charRetval ); } //*******************************************
If you want to use external memory, you need to properly configure the external interface and CS signal. This is done from the Start.s configuration file. (I guess you are using LPC2294 or similar with external interface). Very important are the timings and of course the bus width (8,16 or 32-bit). Next step is to describe a memory layout to LA linker from uVision. When everything is properly configured it should work also with external RAM. You may take a Hello example from \Keil\ARM\Boards\Phytec\LPC229x\Hello as a reference how the external RAM should be configured.