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",);
3180 jacho 22 printf("(c) MLAB 2013 JACHO \r\n",);
3095 jacho 23  
24 signed int8 MSB;
25 byte LSB;
26 float t;
27  
28 while(TRUE)
29 {
30  
31  
32  
33 i2c_start();
34 I2C_Write(0x9E);
35 I2C_write(0x00);
36 i2c_stop();
37 i2c_start();
38 I2C_Write(0x9F);
39 MSB=i2c_read(1);
40 LSB=i2c_read(0);
41 i2c_stop();
42  
43 t = (float)(LSB)/256.0;
44 t = (float)(MSB+t);
45  
46 printf("Teplota: %f (C)\r\n", t);
47 delay_ms(500);
48 }
49 }
50