putrsLCD((const far rom char )* "FinalYearProject");
putsLCD
#include<p18f4520.h>
#pragma config LVP = OFF
#pragma config OSC = INTIO67
#include "picdem2lcd.h"
#include<i2c.h>
#include<delays.h>
void main()
{
unsigned int LastTemp = 0;
TRISB = 0x00;
PORTB = 0x00;
TRISD = 0x00;
PORTD = 0x00;
SSPSTAT = 0x80; //Disable SMBus & Slew Rate Control
SSPCON1 = 0x28; //Enable MSSP Master
SSPADD = 19; //Fosc = 48MHs HS+PLL for 100kHz
SSPCON2 = 0x00; //Clear MSSP Conrol Bits
while(1)
{
IdleI2C(); // ensure module is idle
StartI2C(); // initiate START condition
while ( SSPCON2bits.SEN ); // wait until start condition is over
Delay10TCYx(10);
WriteI2C( 0b10011010 ); // Send TC74 address (Write; LSB=0 10011010)
IdleI2C(); // ensure module is idle
WriteI2C( 0 ); // Select Temperature Register
IdleI2C(); // ensure module is idle
RestartI2C(); // generate I2C bus restart condition
while ( SSPCON2bits.RSEN ); // wait until re-start condition is over
WriteI2C( 0b10011011); // Send TC74 address (Read; LSB=1 10011011)
IdleI2C(); // ensure module is idle
ReadI2C(); // read in the temp
NotAckI2C(); // send not ACK condition
while ( SSPCON2bits.ACKEN ); // wait until ACK sequence is over
StopI2C(); // send STOP condition
while ( SSPCON2bits.PEN ); // wait until stop condition is over
LastTemp = SSPBUF; // LastTemp is a Global unsigned char
}
}
printf("Temp[C] = %d ",&LastTemp);
unsigned int LastTemp
signed int LastTemp
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?