Line 1... |
Line 1... |
1 |
#include "D:\Honza\MLAB\Modules\Sensors\LTS01A\SW\PIC16F887\main.h" |
1 |
#include "main.h" |
2 |
|
2 |
|
3 |
#define S_SDA PIN_C3 |
3 |
#define S_SDA PIN_C4 |
4 |
#define S_SCL PIN_C4 |
4 |
#define S_SCL PIN_C3 |
5 |
#use i2c(master, sda=S_SDA, scl=S_SCL) |
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 |
6 |
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8) |
7 |
|
7 |
|
8 |
//Adresa pro VDD, VDD, VDD W 0x9E R 0x9F |
- |
|
9 |
//Adresa pro GND GND GND W 0x90 R 0x91 |
8 |
#include "../LTS01.h" |
10 |
|
9 |
|
11 |
void main() |
10 |
void main() |
12 |
{ |
11 |
{ |
13 |
|
12 |
|
14 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
13 |
setup_adc_ports(NO_ANALOGS|VSS_VDD); |
Line 18... |
Line 17... |
18 |
setup_timer_1(T1_DISABLED); |
17 |
setup_timer_1(T1_DISABLED); |
19 |
setup_timer_2(T2_DISABLED,0,1); |
18 |
setup_timer_2(T2_DISABLED,0,1); |
20 |
setup_ccp1(CCP_OFF); |
19 |
setup_ccp1(CCP_OFF); |
21 |
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard |
20 |
setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard |
22 |
|
21 |
|
23 |
printf("Simple Thermomether \r\n",); |
22 |
printf("Simple Thermomether with LTS01A sensor \r\n",); |
24 |
printf("(c) MLAB 2013 JACHO \r\n",); |
23 |
printf("(c) MLAB.cz 2013 JACHO \r\n",); |
25 |
|
- |
|
26 |
signed int8 MSB; |
- |
|
27 |
byte LSB; |
- |
|
28 |
float t; |
- |
|
29 |
|
24 |
|
30 |
while(TRUE) |
25 |
while(TRUE) |
31 |
{ |
26 |
{ |
32 |
|
- |
|
33 |
|
- |
|
34 |
|
- |
|
35 |
i2c_start(); |
- |
|
36 |
I2C_Write(0x90); |
- |
|
37 |
I2C_write(0x00); |
- |
|
38 |
i2c_stop(); |
- |
|
39 |
i2c_start(); |
- |
|
40 |
I2C_Write(0x91); |
- |
|
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); |
27 |
printf("T: %f\r\n", LTS01_get_temp()); |
49 |
delay_ms(500); |
28 |
delay_ms(500); |
50 |
} |
29 |
} |
51 |
} |
30 |
} |
52 |
|
31 |
|