CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

please tell me

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
i'm child
Guest







please tell me
PostPosted: Thu Oct 19, 2006 4:13 pm     Reply with quote

dear all....

i want to read temperature from TC74. but when i run this code i read
temperature =-1 why?

what wrong!! please tell me



#include<18f452.h>


#device ADC=10 //use ADC 8 bit convision
#use delay(clock=4000000)
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7)
#use I2C(master,sda=PIN_C4,scl=PIN_C3)

//Define address on Temperature Sensor :0100 1101
#define Sensor_ID 0b01001101
#include<stdlib.h>
#include "input.c"


unsigned int TempRead(void){
unsigned int Data;

i2c_start();
i2c_write(Sensor_ID);
Data=i2c_read(0);
i2c_stop();
delay_ms(200);
return(Data);
}


void main(void){
unsigned int Data;
int16 readin; //variable readin---->buffer read in
set_tris_b(0xF0); //set tris b for low nibble as output
output_b(0x00);// Clear port B


setup_adc_ports(RA0_ANALOG); //Select RA0 to analog
setup_adc(ADC_CLOCK_INTERNAL);//Select internal clock
set_adc_channel(0);//Select channel


Printf("\t\t ..::Hello world This is a testing a RS-232::..\n\r");

for(;;){
Data=TempRead();
printf("this is temperature : %d C' \n\r",Data);
readin=read_adc(); //Read in and assigned in readin variable
printf("ADC value is : %w \n\r",readin);


if(readin<0>0 && readin <255>255 && readin <512>512 && readin <767>767 && readin <=1023){
output_b(0x0F);
delay_ms(500);

}
}//for loop
}//main
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Oct 19, 2006 5:33 pm     Reply with quote

Use the sample code for the TC74 shown in the link below:
http://www.ccsinfo.com/forum/viewtopic.php?t=28089&start=10
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Thu Oct 19, 2006 11:31 pm     Reply with quote

Hi,

Quote:

//Define address on Temperature Sensor :0100 1101
#define Sensor_ID 0b01001101
#include
#include "input.c"


Whats the extra #include directive for , it has no .c file specified ??

thanks
arunb
i'm child
Guest







PostPosted: Fri Oct 20, 2006 5:27 am     Reply with quote

Thank alot PCM programmer.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group