softdev:tempmeter3
差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
| softdev:tempmeter3 [2013/01/07 23:47] – [ソース] king | softdev:tempmeter3 [2013/07/15 20:25] (現在) – 外部編集 127.0.0.1 | ||
|---|---|---|---|
| 行 18: | 行 18: | ||
| ポート初期化他 | ポート初期化他 | ||
| - | < | + | < |
| #include < | #include < | ||
| #define _XTAL_FREQ 4000000 | #define _XTAL_FREQ 4000000 | ||
| 行 48: | 行 48: | ||
| __CONFIG(CP_OFF & BOREN_ON | __CONFIG(CP_OFF & BOREN_ON | ||
| + | main() | ||
| + | { | ||
| + | /* Note: The ANSEL and CMCON0 registers must be initialized to configure an analog | ||
| + | * channel as a digital input. Pins configured as analog inputs will read ‘0’. | ||
| + | */ | ||
| GPIO = 0x00; /* IO initialize */ | GPIO = 0x00; /* IO initialize */ | ||
| CMCON0 = 0x07; /* Comparator function CM210=111(disable)*/ | CMCON0 = 0x07; /* Comparator function CM210=111(disable)*/ | ||
| 行 60: | 行 65: | ||
| ADON = 1; | ADON = 1; | ||
| + | </ | ||
| + | |||
| + | ADC計算部(ごめん、long使ってる) | ||
| + | <code c> | ||
| + | char avg, | ||
| + | int andata, | ||
| + | long temp10; | ||
| + | |||
| + | andata = 0; | ||
| + | for(avg=0; | ||
| + | __delay_ms(5); | ||
| + | GO = 1; | ||
| + | while(GO); | ||
| + | andata += (ADRESH<< | ||
| + | } | ||
| + | andata = andata / HEIKIN ; | ||
| + | temp10 = (long)andata * 5000 - 2457600; | ||
| + | temp10 = temp10 / 4096; | ||
| + | temp = (int)temp10; | ||
| </ | </ | ||
softdev/tempmeter3.1357570072.txt.gz · 最終更新: (外部編集)
