IDEは統合開発環境で、エディタ、デバッカ、シミュレータなどほとんどのプログラムを内蔵しています。MPLAB X IDEは8bit~32bitマイコンで共通で使用できます。 コンパイラはC言語のようなコンパイラ言語をコンパイルして機械語に翻訳するプログラムです。Cコンパイラは別にインストールし、MPLAB X IDE に統合します。
// CONFIG1
#pragma config FOSC = INTRC_NOCLKOUT // 発振回路設定 Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN)
#pragma config WDTE = OFF // Watchdog Timer Enable bit (WDT disabled and can be enabled by SWDTEN bit of the WDTCON register)
#pragma config PWRTE = OFF // Power-up Timer Enable bit (PWRT disabled)
#pragma config MCLRE = ON // 外部リセット/汎用入力の選択で外部リセット有効化 RE3/MCLR pin function select bit (RE3/MCLR pin function is MCLR)
#pragma config CP = OFF // Code Protection bit (Program memory code protection is disabled)
#pragma config CPD = OFF // Data Code Protection bit (Data memory code protection is disabled)
#pragma config BOREN = OFF // Brown Out Reset Selection bits (BOR disabled)
#pragma config IESO = ON // オシレータのスタートアップとコード実行の潜在時間を最小化Internal External Switchover bit (Internal/External Switchover mode is enabled)
#pragma config FCMEN = ON // オシレータの故障の場合さえ、デバイスが作動し続けるのを許容するように設計Fail-Safe Clock Monitor Enabled bit (Fail-Safe Clock Monitor is enabled)
#pragma config LVP = OFF // Low Voltage Programming Enable bit (RB3 pin has digital I/O, HV on MCLR must be used for programming)
// CONFIG2
#pragma config BOR4V = BOR40V // リセットしきい値を4V Brown-out Reset Selection bit (Brown-out Reset set to 4.0V)
#pragma config WRT = OFF // Flash Program Memory Self Write Enable bits (Write protection off)
電源供給するように設定します(私のライターは安く買ったからか電源を供給する機能がうまくいきませんでした)。マイコンは電源がないと動作しませんので、ライターか回路から電源を供給して下さい。 project上右クリックでpropaties、hardware toolからPICkit3を選択、pickit3からpowerで、チェックボックスにチェック。マイコンのデータシートにWide Operating Voltage Range (2.0V-5.5V)とあったので、5.0Vの電圧を供給します。
PICkit 3 is trying to supply 5.250000 volts from the USB port, but the target VDD is measured to be 4.875000 volts. This could be due to the USB port power capabilities or the target circuitry affecting the measured VDD.
私はライターが壊れていたので、無理やり外部から接続できるようにしました。
Programming...
The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0xfff
configuration memory
Programming/Verify complete