1

I am using Keil uVision v5.14 to compile some code for an nrf51xx cpu. I have always used a header file called nrf_delay.h which has some delay routines encoded in assembler. All of a sudden, receive the above error during compilation, on all the "NOP" lines:

#if defined ( __CC_ARM   )
static __ASM void __INLINE nrf_delay_us(uint32_t volatile number_of_us)
{
loop
    SUBS    R0, R0, #1
    NOP
    NOP
    NOP
    NOP
    NOP
    NOP
    NOP
    NOP
    NOP
    NOP
    NOP
    NOP
    BNE    loop
    BX     LR
}
#elif defined ( __ICCARM__ )
...

text of error:

..\..\..\Include\nrf_delay.h(12): error: A1137E: Unexpected characters at end of line
..\..\..\Include\nrf_delay.h(13): error: A1137E: Unexpected characters at end of line
..\..\..\Include\nrf_delay.h(14): error: A1137E: Unexpected characters at end of line
..\..\..\Include\nrf_delay.h(15): error: A1137E: Unexpected characters at end of line
..\..\..\Include\nrf_delay.h(16): error: A1137E: Unexpected characters at end of line
..\..\..\Include\nrf_delay.h(17): error: A1137E: Unexpected characters at end of line
..\..\..\Include\nrf_delay.h(18): error: A1137E: Unexpected characters at end of line
..\..\..\Include\nrf_delay.h(19): error: A1137E: Unexpected characters at end of line
..\..\..\Include\nrf_delay.h(20): error: A1137E: Unexpected characters at end of line
..\..\..\Include\nrf_delay.h(21): error: A1137E: Unexpected characters at end of line
..\..\..\Include\nrf_delay.h(22): error: A1137E: Unexpected characters at end of line
..\..\..\Include\nrf_delay.h(23): error: A1137E: Unexpected characters at end of line

The weird thing it, there are absolutely no extra characters after NOP. I have tried also substituting nrf_delay.h with an older version, or changing the project settings to match a working one, but no luck.

The whole thing is enclosed between

#if defined ( __CC_ARM   )

but I am not sure whether "_CC_ARM" or "ICCARM" is defined. The C compiler is Armcc V5.05.

update

I have started from a working project, and I have added the changes I have mad from last time step by step. It seems that simply including nrf_delay.h in the new .c file of the project triggers the problem.

However, nrf_delay.h is included in many other .c files, and nrf_delay_us() is used many times with no such a problem.

update 2 - solved, but still a mistery So, I have some #defines on top of my .c file. If I put it like this:

#include <stdio.h>
#include <stdint.h>
#include "fw_update.h"
#include "registers.h"
#include "nrf51.h"
#include "boarddef.h"
#include "hal.h"
#include "nrf_delay.h" <-- this is giving the error

if I put it like this:

#include <stdio.h>
#include <stdint.h>
#include "nrf_delay.h" <-- this works!
#include "fw_update.h"
#include "registers.h"
#include "nrf51.h"
#include "boarddef.h"
#include "hal.h"

any idea why?

Vitomakes
  • 315
  • 4
  • 12

2 Answers2

0

An unexpected #define of NOP occurs in a header file.

The 12 errors corresponded to the 12 NOP implying an issue with NOP and not some line-ending issue. Also the occurrence of the error changed relative to header placement.

Having such a short generic token NOP defined in some header file has these unfortunate effects. IMO, if reasonably possible, re-factory the #define.

Community
  • 1
  • 1
chux - Reinstate Monica
  • 143,097
  • 13
  • 135
  • 256
0

I had this error within a .s file.

Solved error A1137E by checking the checkbox "Assemble by using ArmClang V6" In options dialog, tab ASM

rundekugel
  • 1,118
  • 1
  • 10
  • 23