1

我正在使用 Keil uVision v5.14 为 nrf51xx cpu 编译一些代码。我一直使用一个名为 nrf_delay.h 的头文件,它有一些用汇编程序编码的延迟例程。突然,在编译过程中,在所有“NOP”行上都收到上述错误:

#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__ )
...

错误文本:

..\..\..\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

奇怪的是,NOP 之后绝对没有多余的字符。我也尝试过用旧版本替换 nrf_delay.h,或者更改项目设置以匹配工作设置,但没有运气。

整个东西都被包围在

#if defined ( __CC_ARM   )

但我不确定是否定义了“_CC_ARM”或“ ICCARM ”。C 编译器是 Armcc V5.05。

更新

我是从一个工作项目开始的,我已经逐步添加了我上次疯狂的更改。似乎只是在项目的新 .c 文件中包含 nrf_delay.h 会触发问题。

但是,nrf_delay.h 包含在许多其他 .c 文件中,并且 nrf_delay_us() 被多次使用,没有这样的问题。

更新 2 - 已解决,但仍然是个谜 所以,我的 .c 文件顶部有一些#defines。如果我这样说:

#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

如果我这样说:

#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"

知道为什么吗?

4

2 回答 2

0

头文件中发生了意外。 #defineNOP

12 个错误对应于 12 个,NOP暗示存在问题NOP而不是某些行尾问题。错误的发生也相对于标题位置发生了变化。

在某些头文件中定义如此短的通用标记NOP会产生这些不幸的影响。IMO,如果可能的话,重新制造#define.

于 2015-11-26T14:35:34.560 回答
0

我在 .s 文件中遇到了这个错误。

通过选中“使用 ArmClang V6 组装”复选框解决了错误 A1137E 在选项对话框中,选项卡 ASM

于 2020-02-26T11:01:19.823 回答