ユーザ用ツール

サイト用ツール


softdev:tempmeter3

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
softdev:tempmeter3 [2013/01/07 23:47] – [ソース] kingsoftdev:tempmeter3 [2013/07/15 20:25] (現在) – 外部編集 127.0.0.1
行 18: 行 18:
  
 ポート初期化他 ポート初期化他
-<code>+<code c++>
 #include <pic.h> #include <pic.h>
 #define _XTAL_FREQ 4000000 #define _XTAL_FREQ 4000000
行 48: 行 48:
 __CONFIG(CP_OFF & BOREN_ON  & PWRTE_ON & WDTE_OFF & FOSC_INTOSCIO) ; __CONFIG(CP_OFF & BOREN_ON  & PWRTE_ON & WDTE_OFF & FOSC_INTOSCIO) ;
  
 +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;
  
 +</code>
 +
 +ADC計算部(ごめん、long使ってる)
 +<code c>
 +char avg,fugo,d3,d2,d1,loop;
 +int andata,temp;
 +long temp10; // AD変換値の10倍で途中まで計算(long型とする)
 +
 +andata = 0;
 +for(avg=0;avg<HEIKIN;avg++){
 +  __delay_ms(5);
 +  GO = 1;
 +  while(GO);
 +  andata += (ADRESH<<8) | ADRESL ;
 +}
 +andata = andata / HEIKIN ;
 +temp10 = (long)andata * 5000 - 2457600;
 +temp10 =  temp10 / 4096;
 +temp   = (int)temp10;
 </code> </code>
  
  
  
softdev/tempmeter3.1357570072.txt.gz · 最終更新: 2013/07/15 20:28 (外部編集)