Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] SPI temperature sensor interface problem

Status
Not open for further replies.

engr.waqas

Full Member level 3
Joined
Jul 21, 2009
Messages
172
Helped
13
Reputation
26
Reaction score
10
Trophy points
1,298
Location
karachi,Pakistan
Activity points
2,342
I am trying to interface TC72 temperate sensor which is SPI based. I am only getting response of oxff from MSB register of the sensor. Note that MSB register contain MSB of temperature reading. My code is
void main() {
trisc.f0=0;
trisd=0;
spi1_init();
portc.f0=1;//chip enable
delay_ms(250) ;
spi1_write(0x80); //control register address
spi1_write(0x04);//continuous mode
delay_ms(250);
portc.f0=0;//chip disable
delay_ms(250);

portc.f0=1;//chip enable
delay_ms(250) ;
portd=spi1_read(0x02);//MSB register address
delay_ms(200);
portc.f0=0;//chip disable
}
 

What is the resolution of the ADC that your are using? And whether sensor can read both positive and negative temperatures?
 

resolution is 8 bit. yes the sensor can give both positive and negative values. Actually i am simulating the circuit in proteus and i have set the sensor to positive temperature. The issue is at every positive temperature i get only 0xff as output.
 

I m not sure abt the simulation of the Temperature sensor in Proteus...as i had never tried before..

But if u get 0xFF as the output that means either you didnt configure the registers in the Temp Senor correctly or the output of the Temp Sensor is not validated correctly...check in the conversion part of the values read from the temperature sensor.

---------- Post added at 08:51 ---------- Previous post was at 08:26 ----------

**broken link removed**

Please check this website from Microchip for further clarification..
 

Thanks to all of you for help.
The problem is solved. Actually the problem was i was using wrong SPI mode as i was using spi_init() in default mode.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top