少し前に作業した。
NXP社のLPCXpresso IDE 8.1.0 インストール
LPC810で、ファーム書込み / Lチカなど試してみたいと思います。
# 準備 、(覚えている範囲で 抜けがあるかもしれません。)
# download
https://www.lpcware.com/lpcxpresso/download
# 参考, install , Activation など
LPC810(2) 〜 LPCXpressoを使う(1)
http://mits-whisper.info/post/81547764577/lpc8102-lpcxpresso%E3%82%92%E4%BD%BF%E3%81%861
http://suzuki-soft.jp/ucon-board/lpc810/lpc810-tool-install/
*) Activationは、
初期のコードサイズが8kの制限を拡張できました。
ROM= 8K 以下の容量であれば不要みたいです。
#ライブラリのインポート 作業フォルダにコピー、
パス例:
C:\nxp\LPCXpresso_8.1.0_597\lpcxpresso\Examples\Legacy\NXP\LPC800
NXP_LPC8xx_SampleCodeBundle.zip を解凍しておきます。
import
[File] -[import], Existing Project into Workspace を選択
CMSIS_CORE_LPC8xx
lpc800_driver_lib
ビルドしておきます。
# Lチカ
# Blinky を作業フォルダにコピー
例:work/Blinky
import
[File] -[import], Existing Project into Workspace を選択
Select root directory=
C:\nxp\work\Blinky
[Finish]おす
# 設定
project- 右クリック [Properties] - Project References
CMSIS_CORE_LPC8xx
lpc800_driver_lib
をチェック
# [C/C++ Build] - MCU setting - LPC8xx
LPC810 を選択。
# [C/C++ Build] -Settings- Build steps
通常ビルドすると、hex出力されませんので、処理追加します。
post-build steps を追加。
改行されていますが、文節は[;]などで連結が必要だったりルールに注意です。
arm-none-eabi-size "${BuildArtifactFileName}";
arm-none-eabi-objcopy -O ihex "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.hex";
# code : main.c
LPC810でLED 配線する為に
PIO 0_1に書き換えてます。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef __USE_CMSIS
#include "LPC8xx.h"
#endif
#include "type.h"
#include "lpc8xx_clkconfig.h"
#include "lpc8xx_gpio.h"
#include "lpc8xx_mrt.h"
extern uint32_t mrt_counter;
#define mLed 1
void SwitchMatrix_Init()
{
/* Enable SWM clock */
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<7);
/* Pin Assign 8 bit Configuration */
/* none */
/* Pin Assign 1 bit Configuration */
/* SWCLK */
/* SWDIO */
/* RESET */
LPC_SWM->PINENABLE0 = 0xffffffb3UL;
}
/* Main Program */
int main (void) {
uint32_t regVal;
//SwitchMatrix_Init();
SystemCoreClockUpdate();
/* Config CLKOUT, mostly used for debugging. */
regVal = LPC_SWM->PINASSIGN8 & ~( 0xFF << 16 );
LPC_SWM->PINASSIGN8 = regVal | ( 12 << 16 ); /* P0.12 is CLKOUT, ASSIGN(23:16). */
CLKOUT_Setup( CLKOUTCLK_SRC_MAIN_CLK );
#if 0
regVal = LPC_SWM->PINASSIGN0 & ~( (0xFF << 0) | (0xFF << 8) );
LPC_SWM->PINASSIGN0 = regVal | ( (2 << 0) | (3 << 8) ); /* P0.2 is UART0 TX, ASSIGN(7:0); P0.3 is UART0 RX. ASSIGN(15:8). */
#endif
/* Enable AHB clock to the GPIO domain. */
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<6);
/* Set port p0.7 to output */
// GPIOSetDir( 0, 7, 1 );
GPIOSetDir( 0, mLed, 1 );
init_mrt(0x8000);
while (1) /* Loop forever */
{
/* I/O configuration and LED setting pending. */
if ( (mrt_counter > 0) && (mrt_counter <= 200) )
{
// GPIOSetBitValue( 0, 7, 0 );
GPIOSetBitValue( 0, mLed, 0 );
}
if ( (mrt_counter > 200) && (mrt_counter <= 400) )
{
// GPIOSetBitValue( 0, 7, 1 );
GPIOSetBitValue( 0, mLed, 1 );
//GPIOSetBitValue( 0, 0, 1 );
}
else if ( mrt_counter > 1200 )
{
mrt_counter = 0;
}
}
}
pinOut
# Build , 約 2.5KB程度
Building target: Blinky.axf
Invoking: MCU Linker
arm-none-eabi-gcc -nostdlib -L"C:\nxp\work\CMSIS_CORE_LPC8xx\Debug" -L"C:\nxp\work\lpc800_driver_lib\Debug" -Xlinker -Map="Blinky.map" -Xlinker --gc-sections -mcpu=cortex-m0 -mthumb -T "Blinky_Debug.ld" -o "Blinky.axf" ./src/cr_startup_lpc8xx.o ./src/crp.o ./src/main.o -llpc800_driver_lib -lCMSIS_CORE_LPC8xx
Finished building target: Blinky.axf
make --no-print-directory post-build
Performing post-build steps
arm-none-eabi-size "Blinky.axf";arm-none-eabi-objcopy -O ihex "Blinky.axf" "Blinky.hex";
text data bss dec hex filename
2372 4 132 2508 9cc Blinky.axf
# 書込み ,Flash Magic で書込みます。
# ハマリどころ
ビルドエラーは、post-build steps の記述ミスや、
書き込んで、正常動作しない場合は、 MCU setting の設定が消去されていたり
再度 LPC810に設定など修正 がありました。
# Lチカできました 。