PC版 SYSLAB blog  http://syslab.asablo.jp/blog/......

CQ-LM3S3748 (3) blinky LED
2012-10-22


いつもの LED 点滅からはじめよう。
ベースにしたのは「ファームウェア開発パッケージ」 SW-EK-LM3S3748-9453.exe の boards\ek-lm3s3748\blinky 。変更したのは blinky.c と blinky.ld 。そのまま使ったのは startup_gcc.c 。

blinky.ld は MEMORY の部分のみ変更。オフセット 0x1800 を入れてみた。
変更前
MEMORY
{
    FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00020000
    SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000
}
変更後
MEMORY
{
    FLASH (rx) : ORIGIN = 0x00001800, LENGTH = 0x0001E800
    SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00010000
}


blinky.c は port.f0 を port.g2 に変更しただけ。

  //***************************************************************************** // //! \addtogroup example_list //!

Blinky (blinky)

//! //! A very simple example that blinks the on-board LED. // //***************************************************************************** //***************************************************************************** // // Blink the on-board LED. // //***************************************************************************** int main(void) { volatile unsigned long ulLoop; // // Enable the GPIO port that is used for the on-board LED. // SYSCTL_RCGC2_R = SYSCTL_RCGC2_GPIOG; // // Do a dummy read to insert a few cycles after enabling the peripheral. // ulLoop = SYSCTL_RCGC2_R; // // Enable the GPIO pin for the LED (PG2). Set the direction as output, and // enable the GPIO pin for digital function. // GPIO_PORTG_DIR_R = 0x04; GPIO_PORTG_DEN_R = 0x04; // // Loop forever. // while(1) { // // Turn on the LED. // GPIO_PORTG_DATA_R |= 0x04; // // Delay for a bit. // for(ulLoop = 0; ulLoop < 200000; ulLoop++) { } // // Turn off the LED. // GPIO_PORTG_DATA_R &= ~(0x04); // // Delay for a bit. // for(ulLoop = 0; ulLoop < 200000; ulLoop++) { } } }


後は μVision の設定だけだ。
では Target の設定を見ていこう。まず Device 、当然 LM3S3748 を選択。 禺画像]

μVision が気に入っている理由のひとつ以下のように外部 Tool が簡単に使えること。ここでは elf file からバイナリファイルを作る。
arm-none-eabi-objcopy.exe -O binary !L.elf !L.bin 禺画像]

Compile Thumb Code にチェックを入れる。 禺画像]

リンカースクリプトファイルを指定する。 禺画像]

ここでも外部 Tool LMFlash.exe が簡単に使える。もちろん Device Database に登録しているのでいちいち書き込む必要もない。
Command: C:\Program Files\Texas Instruments\Stellaris\LM Flash Programmer\LMFlash.exe
Arguments: -r -v --interface=USB --offset=0x1800 "!L.bin"

続きを読む

[ARM]
[マイコン]

コメント(全0件)
コメントをする


記事を書く
powered by ASAHIネット