MPLAB C30の使用方法

PIC24、dsPIC30FおよびdsPIC33F向けのCコンパイラです。
※ ここで使用しているのは、MPLAB C Compiler for dsPIC v3.20 Standard-Eval Versionです。

(MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs)

Student Editionは無料で提供されていますが60日の使用制限があり、期間経過後は設定可能な最適化レベルがレベル1のみに制限されます。しかし実用上は問題とならないでしょう。

インストール

次のページからダウンロードします。
MPLAB C Compilers

ダウンロードしたファイルを実行します。

MPLAB C30 セットアップ実行ファイル

MPLAB C30 インストーラー

評価版であるための制限について解説されます。
MPLAB C30 利用制限通知

MPLAB C30 ライセンス

すべてのユーザーから使用できるようにするか、確認を求められます。
MPLAB C30 利用ユーザーの確認

インストールの種類を選択します。ここでは[Custom]を選択するものとします。
MPLAB C30 インストールの種類の選択

MPLAB C30 インストールディレクトリの選択

MPLAB C30 インストールコンポーネントの選択

環境変数の変更について確認を求められます。
MPLAB C30 環境変数の変更についての確認

MPLAB IDEから使用できるようにするための、レジストリの変更について確認を求められます。
MPLAB C30 レジストリ変更についての確認

MPLAB C30 インストールの確認

MPLAB C30 インストール中

MPLAB C30 インストール完了

動作確認

インストール後のディレクトリにあるサンプルのバッチファイルを実行して、コンパイラの動作を確認できます。

C:\Program Files\Microchip\MPLAB C30\examples\MPLABC30_Getting_Started\run_hello.bat

正常に実行されると、次のように出力されます。

C:\Program Files\Microchip\MPLAB C30\examples\MPLABC30_Getting_Started>run_hello.bat
C:\Program Files\Microchip\MPLAB C30\examples\MPLABC30_Getting_Started>pic30-gcc -ansi -Os hello.c -o hello.cof -Wl,--heap=0
C:\Program Files\Microchip\MPLAB C30\examples\MPLABC30_Getting_Started>pic30-bin2hex hello.cof
**********************************************************
*** The following simulation should take about 1 minute **
**********************************************************

C:\Program Files\Microchip\MPLAB C30\examples\MPLABC30_Getting_Started>sim30 hello.cmd
This is the Microchip dsPIC30 simulator version [CLI v4.10.02.00]
Copyright (c) 2009 Microchip Technology Inc. All rights reserved.
Device: 'dspic30super'
Instruction set version [ISA2 Rev A 2003/01/31]
Program space:-
[000000..03ffff] Program FLASH
[7ff000..7fffff] Data FLASH
[f80000..f8000d] Configuration Registers
Data space:-
[0000..ffff] X Data RAM
[3000..ffff] Y Data RAM
Simulated Peripherals:-
HsAdc   Uart1   Uart2   Timer1  Timer2
Timer3  Timer4  Timer5  IC1     IC2
IC3     IC4     IC5     IOPortA IOPortB
IOPortC IOPortD IOPortE IOPortF IOPortG
KeySequenceEnable
dsPIC30> lp hello.hex
dsPIC30> rp
dsPIC30> io nul
dsPIC30> e
dsPIC30> q
dsPIC30> Hello, world!

コンパイルに失敗する場合

以下のようなメッセージが出力され、コンパイルに失敗することがあります。

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

このような場合の原因の1つに、環境変数の設定があります。

詳細な理由は不明ですが、ユーザー環境変数に「TEMP」「TMP」が定義されていないと、コンパイルに失敗します。(これらの変数は既定で定義されています)

環境変数の設定

データ型

種類 ビット幅
整数 char 8
short 16
int 16
long 32
long long 64
浮動小数点数 float 32
double 32
long double 64
ポインタ ポインタ 16
※ 複数バイトの型では、データはリトルエンディアン (little endian) で格納されます。

警告 (Warning)

no newline at end of file

ソースファイルの最後の行が、復帰改行文字で終了していない場合に表示されます。