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 support@ccsinfo.com

A/D conversion for temperature sensor LM35

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
maria



Joined: 31 Jul 2005
Posts: 1

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

A/D conversion for temperature sensor LM35
PostPosted: Sun Jul 31, 2005 10:57 am     Reply with quote

I'm trying to do A/D conversion for the Temperature sensor LM35 and my code doesnt work, can any of you guys tell me what's wrong with my code.. Code:


the error that gives me is this:

Error 23 "C:testadtemp.c" Line 6(8,9): Can not change device type this far into the code
*** Error 48 "C:testadtemp.c" Line 6(9,12): Expecting a (
*** Error 43 "C:testadtemp.c" Line 6(13,14): Expecting a declaration
is in the line where i declared
#device ADC=8

#include <16F877.h>
#include <STDLIB.H>

#device ADC=8 //set for 8 bit A/D
#use delay(clock=4000000)

int Tempvalue=0;
int Temp;

//Define the A/D control register
#BYTE ADCON0=0X01

//Check Temperature Function
void check_Temp() {


set_adc_channel(0);
while(input(PIN_A0))
{
Tempvalue=read_adc();
}

if(Tempvalue>=0) //64 to test put 0
{ Temp=1;
output_high(PIN_B0);
}
else
{ Temp=0;
output_low(PIN_B0);
}

}








HELP !!!
LomasS
Guest







PostPosted: Sun Jul 31, 2005 12:58 pm     Reply with quote

It looks like a conflict between the #device and something in STDLIB.H.
Place the #device ADC=8 between the other #includes:

#include <16F877.h>
#device ADC=8
#include <STDLIB.H>

That compiled OK for me.

Note that your code is incomplete as there is no main() function.

Steve.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Sun Jul 31, 2005 5:04 pm     Reply with quote

Make sure that you only have 1 C file if using MPLAB. A common mistake is to use multiple source files in the project workspace. You cannot do this. You must include any C files in your main C file by using the #include
languer



Joined: 09 Jan 2004
Posts: 144
Location: USA

View user's profile Send private message

Why location of #device ADC=8 is important
PostPosted: Sun Jul 31, 2005 11:34 pm     Reply with quote

Look here to understand why the location of the following command is important.
Code:
#device ADC=8
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