//********************************************************************** /*   『温度計(シリコンダイオード使用)』 */ //********************************************************************** unsigned int measurement() { unsigned int ad, cnt; // ad = 0; for (cnt = 0; cnt < 60; cnt++) { ad += Adc_Read(1); } return (ad / 60); } //********************************************************************** void main() { static unsigned char buf[6], cnt; static unsigned int ad; // OSCCON = 0b01110000; // クロックは8Mhz CMCON = 0b00000111; // コンパレータは使用しない。 // A/D変換を使用する。 ANSEL = 0b00000010; // ポートを初期化する。 TRISA = 0b00111010; TRISB = 0b00001111; // 入力割り込みの設定 INTCON.INTE = 1; INTCON.INTF = 0; OPTION_REG.INTEDG = 1; // LCDを初期化する。 Lcd_Custom_Config(&PORTB,4,5,6,7,&PORTA,0,7,6); Lcd_Custom_Cmd(LCD_CURSOR_OFF); Lcd_Custom_Cmd(LCD_CLEAR); Lcd_Custom_Out(1, 1, "ThermoMeter3"); Delay_ms(500); Lcd_Custom_Cmd(LCD_CLEAR); // INTCON.PEIE = 1; // これ以降の処理で割り込みを許可する。 INTCON.GIE = 1; // これ以降の処理で割り込みを許可する。 // while (1) { ad = measurement(); ad = (double)ad * 4.8828125; WordToStr(ad, buf); Lcd_Custom_Out(2, 1, buf); Lcd_Custom_Out(2, 6, "mV"); // WordToStr(100.0 - (((double)ad - 1380.0) / 10.0), buf); Lcd_Custom_Out(1, 1, buf); Lcd_Custom_Out(1, 6, "゚C"); } } //**********************************************************************