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