Rev Author Line No. Line
3095 jacho 1 #include "D:\Honza\MLAB\Modules\Sensors\LTS01A\SW\PIC16F887\main.h"
2  
3 #define S_SDA PIN_C3
4 #define S_SCL PIN_C4
5 #use i2c(master, sda=S_SDA, scl=S_SCL)
6 #use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD
7  
8  
9 void main()
10 {
11  
12 setup_adc_ports(NO_ANALOGS|VSS_VDD);
13 setup_adc(ADC_CLOCK_DIV_2);
14 setup_spi(SPI_SS_DISABLED);
15 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
16 setup_timer_1(T1_DISABLED);
17 setup_timer_2(T2_DISABLED,0,1);
18 setup_ccp1(CCP_OFF);
19 setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
20  
21 printf("Simple Thermomether \r\n",);
22  
23 signed int8 MSB;
24 byte LSB;
25 float t;
26  
27 while(TRUE)
28 {
29  
30  
31  
32 i2c_start();
33 I2C_Write(0x9E);
34 I2C_write(0x00);
35 i2c_stop();
36 i2c_start();
37 I2C_Write(0x9F);
38 MSB=i2c_read(1);
39 LSB=i2c_read(0);
40 i2c_stop();
41  
42 t = (float)(LSB)/256.0;
43 t = (float)(MSB+t);
44  
45 printf("Teplota: %f (C)\r\n", t);
46 delay_ms(500);
47 }
48 }
49