This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Error in __asm() code

Other Parts Discussed in Thread: CC2538

Hi All, While compiling below code for cc2538 using ccsv5 on ubuntu 12.04. *


 * \addtogroup cc2538-cpu
 * @{
 *
 * \file
 * Implementations of interrupt control on the cc2538 Cortex-M3 micro
 */
/*---------------------------------------------------------------------------*/
unsigned long __attribute__((naked))
cpu_cpsie(void)
{
  unsigned long ret;

  /* Read PRIMASK and enable interrupts */
  __asm("    mrs     r0, PRIMASK\n"
        "    cpsie   i\n"
        "    bx      lr\n"
        : "=r" (ret));

  /* The inline asm returns, we never reach here.
   * We add a return statement to keep the compiler happy */
  return ret;
}
/*---------------------------------------------------------------------------*/
unsigned long __attribute__((naked))
cpu_cpsid(void)
{
  unsigned long ret;

  /* Read PRIMASK and disable interrupts */
  __asm("    mrs     r0, PRIMASK\n"
        "    cpsid   i\n"
        "    bx      lr\n"
        : "=r" (ret));

  /* The inline asm returns, we never reach here.
   * We add a return statement to keep the compiler happy */
  return ret;
}
/*---------------------------------------------------------------------------*/

/** @} */

I got Type#18 expected a ")" error at : "=r" (ret)); and apart from that I am getting some warning they are

Type#1173-D attribute "naked" and Type#551-D variable "ret" is used.

Please let me know how to resolve them. I am not familiar with assemble code and is above code is good way of writing interrupt control.

If not let me know how to modify the above one.

Thanks in ADVANCE,

Jagas

  • Late ansver ... but ..

    I'm 95% linux based and prefer arm-gcc as my compiler:

    The above code looks like arm-gcc (source) code.

    Does TI CCS accept that ?

    Is the CCS compiler arm-gcc "under the hood" ?

    My initial thought would be no , since you get these error messages.

    But if anyone could elaborate , it would be appreciated

    /Bingo

  • The inline assembler syntax you quote won't work with CCS, I'm afraid, because it doesn't offer the ability to reference C symbols from within the assembler code. You will need to rework the code for CCS but, luckily, you will find implementations of exactly these functions in the file driverlib/cpu.c for all supported toolchains in the TivaWare release.