ARm-C inter-networking

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by venkateshkuppan on Sun Apr 21 07:50:09 MST 2013
I am trying out a simple program for ARM-C inter-working. Here is the code:


int Double(int a);
extern int Start(void);
int main(){

int result=0;
printf("in C main\n");
return 0;

int Double(int a)
  printf("inside double func_argument_value=%d\n",a);

  return (a*2);
The assembly file goes as-

.syntax unified
    .cpu cortex-m3

    .global Start
    .global Double

      mov r10,lr
      mov r0,#42
      bl Double
      mov lr,r10
      mov r2,r0
      mov pc,lr

During debugging on LPC1769(embedded artists board), I get an hardfault error on the instruction " result=Start(). " I am trying to do an arm-C internetworking here. the lr value during the execution of the above the statement(result=Start()) is 0x0000029F, where the faulting instruction is,and the pc value is 0x0000029E. This is how I got the faulting instruction in r1

__asm("mrs r0,MSP\n"
"ldr r1,[r0,#24]\n");

Can anybody please explain where I am going wrong? Any solution is appreciated. Thank you in advance.