softdev:pic18
差分
このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン次のリビジョン両方とも次のリビジョン | ||
softdev:pic18 [2012/02/19 17:36] – [Delay] king | softdev:pic18 [2012/02/19 22:55] – [コンフィグbit] king | ||
---|---|---|---|
行 3: | 行 3: | ||
===== コンフィグbit ===== | ===== コンフィグbit ===== | ||
+ | Configuration bitsの設定は、IDEの中で可能だが、プログラムの中に記述する事も出来る。PIC12F675などは __CONFIG( の一文ですんでいたのだが、PIC18Fでは、一つ一つ設定が必要らしい。 | ||
+ | <code txt> | ||
+ | #pragma config OSC = INTIO2 // | ||
+ | #pragma config FSCM = OFF // | ||
+ | #pragma config IESO = OFF // | ||
+ | #pragma config PWRT = ON // | ||
+ | #pragma config BOR = ON // | ||
+ | #pragma config BORV = 42 // | ||
+ | #pragma config WDT = OFF // | ||
+ | #pragma config WDTPS = 32768 // | ||
+ | #pragma config MCLRE = ON // | ||
+ | #pragma config STVR = OFF // | ||
+ | #pragma config LVP = OFF // | ||
+ | #pragma config DEBUG = ON // | ||
+ | #pragma config CP0 = OFF //Code Protection bit Block 0 | ||
+ | #pragma config CP1 = OFF //Code Protection bit Block 1 | ||
+ | #pragma config CPB = OFF //Boot Block Code Protection Bit | ||
+ | #pragma config CPD = OFF //Data EEPROM Code Protectio Bit | ||
+ | #pragma config WRT0 = OFF // | ||
+ | #pragma config WRT1 = OFF // | ||
+ | #pragma config WRTB = OFF //Boot Block Write Protection | ||
+ | #pragma config WRTC = OFF // | ||
+ | #pragma config WRTD = OFF //Data EEPROM Write Protection | ||
+ | #pragma config EBTR0 = OFF // | ||
+ | #pragma config EBTR1 = OFF // | ||
+ | #pragma config EBTRB = OFF //Boot Block Table Read Protection | ||
+ | </ | ||
===== Delay ===== | ===== Delay ===== | ||
- | サンプルで用意されていたDelay関数が無くなっちゃった。あるのか知れんけど。よくわからんから重宝してたのですが、で、includeフォルダをみたら、delays.hと言うのがあった。 | + | サンプルで用意されていたDelay関数が無くなっちゃった。あるのか知れんけど。よくわからんから重宝してたのですが、で、includeフォルダをみたら、delays.hと言うのがあった。わたしも、あんまりよくわかってないので、行き当たりばったりでよくないんですが。 |
<code c++> | <code c++> | ||
行 35: | 行 61: | ||
|Delay10TCYx(20) | |Delay10TCYx(20) | ||
|Delay10TCYx(100) | |Delay10TCYx(100) | ||
+ | |||
+ | 計測にPort出力のH/ | ||
+ | 以上から、1TCYx=510ns(@8MHz)と思われる。8MHzは周期125nsから、TCY=4/ | ||
+ | なので、引数がcharなので | ||
+ | <code c++> | ||
+ | /* 1ms - 1275ms */ | ||
+ | void DelayMs(int t){ | ||
+ | if(t< | ||
+ | Delay1KTCYx(t*2); | ||
+ | } else if(t< | ||
+ | Delay10KTCYx(t/ | ||
+ | } else { | ||
+ | Delay10KTCYx(255); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | これで、いいでしょうか。 | ||
+ | |||
+ | |||
softdev/pic18.txt · 最終更新: 2013/07/15 20:25 by 127.0.0.1