This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Usb bootloader with LPC2148

Hi Friends,

I'm trying to read cpsr and set cpsr with these function. however these functions works fine in eclipse but i have problem using them in keil uvision 4.

static inline unsigned __get_cpsr(void)
{ unsigned long retval; asm volatile (" mrs %0, cpsr" : "=r" (retval) : ); return retval;
}

static inline void __set_cpsr(unsigned val)
{ asm volatile (" msr cpsr, %0": :"r" (val));
} and i get this error:

error: #65: expected a ";"
error: #20: identifier "asm" is undefined
so i used __inline and __asm and now i get this error:

source\main.c(94): error: #18: expected a ")"
source\main.c(94): error: #18: expected a ")"
Any idea on how to fix it? or what is the steps to move these functions in a separate asm file which seems to be a solution.

Thanks
robo

  • www.keil.com/.../armcc_chr1359125006491.htm

    Suspect this has a better chance than GCC/GNU syntax

    __STATIC_INLINE uint32_t __get_CPSR(void)
    {
      register uint32_t __regCPSR     __ASM("cpsr");
      return(__regCPSR);
    }
    
    
    
    
    

  • Hi Friends,
    static inline unsigned asm_get_cpsr(void)
    { unsigned long retval; asm volatile (" mrs %0, cpsr" : "=r" (retval) : /* no inputs */ ); return retval;
    }

    static inline void asm_set_cpsr(unsigned val)
    { asm volatile (" msr cpsr, %0" : /* no outputs */ : "r" (val) );
    }

    I've tried to change the above code but still I'm getting the same errors.

    Im using Keil armcc complier. how to convert the code into ARM ass. language??

  • 1) Why are you posting your original code a second time? Wouldn't it be much, much, much (!) better if you instead posted the modified code? Or are people expected to guess what your code looked like after you tried to rewrite it?

    2) Haven't you already noticed that your code end up with rather bad formatting while the answer you got earlier did show code differently formatted? So didn't you then look for the information on how to post source code clearly described directly above the message input box?

    3) If you want to go all the way to use an assembler file - have you considered looking at Keil's documentation? Or look at all the startup files that are written in assembler?