j'ecris ce code et je simule avec proteus isis mais rien se passe
#include "16F877A.h"
#use delay(clock=1M)
#byte PORTB=0x06
#byte PORTC=0x07
#byte TRISB=0x86
#byte TRISC=0x87
/*SHT75 Sensor Macros*/
#bit SCL=PORTB.0 // Serial Clock pin
#bit SDA=PORTB.1// Serial Data pin
#bit SCL_DIRECTION=TRISB.0
#bit SDA_Direction=TRISB.1
#int_timer0
INT i;
#define MEASURE_TEMPERATURE 0x03
#define MEASURE_RELATIVE_HUMIDITY 0x05
/*SHT75 Temperature and Humidity Sensor Functions*/
void SHT75_Reset(void);
void SHT75_Transmission_Start(void) ;
void SHT75_MCU_ACK(void);
unsigned long Measure_SHT75(unsigned char command);
unsigned long Measure_SHT75_Temperature(void );
unsigned long Measure_SHT75_Relative_Humidit y(void);
unsigned long Measure_True_Humidity(unsigned long SHT75_temperature,unsigned long SHT75_Relative_Humidity);
/*************SHT75 Constants For Calculation************/
const unsigned int C1 = 205;
const unsigned int C2 = 367;
const unsigned int C3 = 16;
const unsigned int D1 = 4010;
const unsigned int D2 = 1;
const unsigned int T1 = 1000;
const unsigned int T2 = 8;
/*
SHT75 Global variables
*/
unsigned long SORH; //This is used to Calculate the True_Humidity
/****************************** **************************/
void main()
{
//setup_timer_0 (RTCC_DIV_4|RTCC_INTERNAL);//fe=4096000/4/4/256=1kHz
//enable_interrupts(INT_TIMER0);
// enable_interrupts(GLOBAL);
void SHT75_Reset()
{
unsigned char i;
SCL = 0;
SDA_Direction = 1;// Define SDA as input to pull the DATA line high
for (i = 1; i <= 20; i++)// repeat 18 times
{
SCL = ~SCL;// invert SCL
}
}
void SHT75_Transmission_Start()
{
SDA_Direction = 1; //data Line High Pulled Up Resistor
SCL = 0;
Delay_us(1);
SCL = 1;
SDA_Direction = 0; //Make Data line as Output pin
SDA = 0;
Delay_us(1);
SCL = 0; //SCL Low
Delay_us(1);
SDA = 0; //SDA Still Low
Delay_us(1);
SCL = 1;
Delay_us(1);
SDA_Direction = 1; //Pull High the Line
SDA = 1; //Not Required
Delay_us(1);
SCL = 0;
}
void SHT75_MCU_ACK()
{
SDA_Direction = 0;
SDA = 0;
SCL = 1;
Delay_us(1);
SCL = 0;
Delay_us(1);
SDA_Direction = 1;
}
unsigned long Measure_SHT75(unsigned char command)
{
unsigned char i,j;
unsigned long k;
j = command;
SCL_Direction = 0;
SHT75_Reset();
SHT75_Transmission_Start();
k = 0;
SDA_Direction = 0;
SCL = 0;
for(i = 1; i <= 8; i++)
{
if ((j & 0x80) == 0x80)
{
SDA_Direction = 1;
}
else
{
SDA_Direction = 0;
SDA = 0;
}
Delay_us(1);
SCL = 1;
Delay_us(1);
SCL = 0;
j <<= 1;
}
SDA_Direction = 1;
SCL = 1;
Delay_us(1);
SCL = 0;
Delay_us(1);
while (SDA == 1);
//Time to Read 2-Bytes from the Sensor
for (i = 1; i <=16; i++)
{
k <<= 1;
SCL = 1;
if (SDA == 1)
{
k = k | 0x0001;
}
SCL = 0;
if (i == 8 )
{
SHT75_MCU_ACK(); //Send Ack from Micro to Sensor
}
}
return k; //Return value For calculations
}
unsigned long Measure_SHT75_Temperature(void )
{
unsigned long SHT75_Temperature;
SHT75_Temperature = Measure_SHT75(MEASURE_TEMPERAT URE);
if(SHT75_Temperature>D1)
{
SHT75_Temperature = D2*(SHT75_Temperature) - D1 ;
}
else
{
SHT75_Temperature = D1 - D2*(SHT75_Temperature);
}
return (SHT75_Temperature);
}
unsigned long Measure_SHT75_Relative_Humidit y(void)
{
unsigned long SHT75_Relative_Humidity;
long temp;
/*
This will Return SOt see Section 4.3 of SHT75 Datasheet
*/
SHT75_Relative_Humidity = Measure_SHT75(MEASURE_RELATIVE _HUMIDITY);
SORH = SHT75_Relative_Humidity; //Used to Calculate the True Humidity
//Thats why the above variable is declared as Global Variable
temp = SHT75_Relative_Humidity*SHT75_ Relative_Humidity;
temp = temp/100000;
temp = temp*C3;
SHT75_Relative_Humidity = C2*SHT75_Relative_Humidity/100;
SHT75_Relative_Humidity = SHT75_Relative_Humidity - temp;
SHT75_Relative_Humidity = SHT75_Relative_Humidity - C1;
/*
This Code is Highly Accurate and Efficient
*/
return SHT75_Relative_Humidity;
}
unsigned long Measure_True_Humidity(unsigned long SHT75_Temperature,unsigned long SHT75_Relative_Humidity)
{
long SHT75_True_Humidity;
long temp;
SHT75_True_Humidity = (long)SHT75_Temperature - 2500;
temp = T1 + T2 * SORH;
temp = temp/100000;
SHT75_True_Humidity = SHT75_True_Humidity + temp + SHT75_Relative_Humidity;
return SHT75_True_Humidity;
}
}
pouvez vous m'aider S.V.P
-----