Rev Author Line No. Line
3095 jacho 1 #include "D:\Honza\MLAB\Modules\HumanInterfaces\TOUCHBOARD01A\SW\PIC16F887\main.h"
2 #define S_SDA PIN_C3
3 #define S_SCL PIN_C4
4 #use i2c(master, sda=S_SDA, scl=S_SCL)
5 #use rs232(baud=9600,parity=N,xmit=PIN_B3,rcv=PIN_B2,bits=8) //rcv TXD xmit RXD
6  
7  
8 void main()
9 {
10  
11 setup_adc_ports(NO_ANALOGS|VSS_VDD);
12 setup_adc(ADC_CLOCK_DIV_2);
13 setup_spi(SPI_SS_DISABLED);
14 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
15 setup_timer_1(T1_DISABLED);
16 setup_timer_2(T2_DISABLED,0,1);
17 setup_ccp1(CCP_OFF);
18 setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
19  
20 printf("Simple Thermomether \r\n",);
21  
22 unsigned int STAV1;
23 unsigned int data1;
24  
25  
26 while(TRUE)
27 {
28  
29  
30  
31 //akcelerometr
32 int1 ack=0;
33 i2c_start(); // If the write command is acknowledged,
34 ack = i2c_write(0xB5);// then the device is ready.
35 i2c_stop();
36 ack=!ack;
37  
38 i2c_stop();
39  
40 i2c_start();
41 I2C_Write(0xB4);
42 I2C_write(0x00);
43 i2c_stop();
44 i2c_start();
45 I2C_Write(0xB5);
46 STAV1=i2c_read(0);
47 i2c_stop();
48  
49 i2c_start();
50 I2C_Write(0xB4);
51 I2C_write(0x01);
52 i2c_stop();
53 i2c_start();
54 I2C_Write(0xB5);
55 data1=i2c_read(0);
56 i2c_stop();
57  
58  
59  
60  
61 printf("Stav: %d (procenta)\r\n", ack);
62 printf("Stav00: %d (procenta)\r\n", STAV1);
63 printf("Stav01: %d (procenta)\r\n", data1);
64 delay_ms(500);
65 }
66 }