Hello,
I'm trying to set up a connexion with a pic 18f452 and a Digital Temperature Sensor (TC72 or TC77).
I have searched many docs but I can't do the program (C ANSI).
I try to send a command (write) to the sensor and a command to modify the config register before reading the temperature but with the SPI debugger (isis), i see that my µC send juste 0x00...
Can you help me to config and read the temperature ?
This is my source :
I tryied to use spi.h but I can't compile the program :/
If you need my card :
**broken link removed**
Thanks.
I'm trying to set up a connexion with a pic 18f452 and a Digital Temperature Sensor (TC72 or TC77).
I have searched many docs but I can't do the program (C ANSI).
I try to send a command (write) to the sensor and a command to modify the config register before reading the temperature but with the SPI debugger (isis), i see that my µC send juste 0x00...
Can you help me to config and read the temperature ?
This is my source :
Code:
#include <p18f452.h>
#include <delays.h>
#define SS PORTAbits.RA2
void init_pic(void);
void init_spi(void);
char i=1;
void init_pic(void)
{
TRISA=0b00000000;
TRISB=0b00000000;
TRISC=0x10;
ADCON1=0x06;
}
void init_spi(void)
{
SSPSTAT=0b01000000;
SSPCON1=0b00110001;
}
void main(void)
{
init_pic();
init_spi();
SS=1;
SSPBUF=0x80;
while(!PIR1bits.SSPIF);
SSPBUF=0x94;
while(!PIR1bits.SSPIF);
PORTB=SSPBUF;
SS=0;
while(1);
}
I tryied to use spi.h but I can't compile the program :/
If you need my card :
**broken link removed**
Thanks.