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 |
|
3180 |
jacho |
8 |
//Adresa pro VDD, VDD, VDD W 0x9E R 0x9F |
|
|
9 |
//Adresa pro GND GND GND W 0x90 R 0x91 |
3095 |
jacho |
10 |
|
|
|
11 |
void main() |
|
|
12 |
{ |
|
|
13 |
|
|
|
14 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
|
|
15 |
setup_adc(ADC_CLOCK_DIV_2); |
|
|
16 |
setup_spi(SPI_SS_DISABLED); |
|
|
17 |
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); |
|
|
18 |
setup_timer_1(T1_DISABLED); |
|
|
19 |
setup_timer_2(T2_DISABLED,0,1); |
|
|
20 |
setup_ccp1(CCP_OFF); |
|
|
21 |
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard |
|
|
22 |
|
|
|
23 |
printf("Simple Thermomether \r\n",); |
|
|
24 |
printf("(c) MLAB 2013 JACHO \r\n",); |
|
|
25 |
|
|
|
26 |
signed int8 MSB; |
|
|
27 |
byte LSB; |
|
|
28 |
float t; |
|
|
29 |
|
|
|
30 |
while(TRUE) |
|
|
31 |
{ |
|
|
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
i2c_start(); |
3180 |
jacho |
36 |
I2C_Write(0x90); |
3095 |
jacho |
37 |
I2C_write(0x00); |
|
|
38 |
i2c_stop(); |
|
|
39 |
i2c_start(); |
3180 |
jacho |
40 |
I2C_Write(0x91); |
3095 |
jacho |
41 |
MSB=i2c_read(1); |
|
|
42 |
LSB=i2c_read(0); |
|
|
43 |
i2c_stop(); |
|
|
44 |
|
|
|
45 |
t = (float)(LSB)/256.0; |
|
|
46 |
t = (float)(MSB+t); |
|
|
47 |
|
|
|
48 |
printf("Teplota: %f (C)\r\n", t); |
|
|
49 |
delay_ms(500); |
|
|
50 |
} |
|
|
51 |
} |
|
|
52 |
|