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.

Compiler: How to emulate __get_IPSR() from CMSIS for gcc



Tool/software: TI C/C++ Compiler

Hi,

I am currently testing an in-house firmware for the MSP432 with TI's armcl compiler. I have unfortunately hit a problem: I cannot find a builtin or helper to extract the contents of the IPSR register (the current interrupt number). I have tried re-using the version from CMSIS for gcc

__attribute__((always_inline)) __STATIC_INLINE uint32_t __get_IPSR(void)
{
  uint32_t result;

  __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
  return(result);
}

In the following way:

 uint32_t __get_IPSR(void) {
   uint32_t result;

   __asm("MRS %0, ipsr" : "=r"(result));
   return result;
 }

But unfortunately the compiler terminates with "error #18: expected a ")" " (about the line containing the __asm statement).

Is someone more familiar with TI's assembly syntax and could help me out please?

Thanks in advance,

Dan

  • Please try this ...

    // Suppress warning about this function not returning a value
    #pragma diag_suppress 994
    __attribute__((naked))
    uint32_t __get_IPSR(void)
    {
       __asm(" MRS R0, IPSR\n");
    }
    // Restore warnings about any non-void function not returning a value
    #pragma diag_default 994

    Thanks and regards,

    -George