KiuFelix
Newbie level 5
I am trying to read temperature values from a LM35. This is how my code is arranged
My code looks ok and when trying to compile, I get this error:
Note the setup errors and the round error yet math.h is included.
When I change to #include <16F877A.h>, No errors except the round error. I am not supposed to use 16F877A though. Only 16F628 is available for me. Someone kindly help.
Thanks
Code:
//************************************************************
// Function: Temperature logger: UART at 9600 baud
// Processor: PIC16F628 at 4 MHz using internal RC oscillator
// Hardware: K4
// Software: CCS PCM
// Author: Cheruiyot Felix, felix@nairobicoder.com
// Credit: Lars Petersen, oz1bxm@pobox.com
//************************************************************
#include <16F628.h>
#fuses INTRC_IO, NOLVP, NOWDT, PUT, BROWNOUT
#device ADC=8;
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=pin_B2, rcv=pin_B1)
void main() {
//Initialize values
unsigned int val;
int t;
setup_adc_ports(AN0);
setup_adc(ADC_CLOCK_INTERNAL);
set_adc_channel(0);
while(read_adc()) {
val=read_adc();
t=round(val*0.48876); //as per http://www.best-microcontroller-projects.com/temperature-recorder.html tutorial
delay_ms(500);
printf("T%d",t); //Output temperature
}
}
My code looks ok and when trying to compile, I get this error:
Code:
Clean: Deleting intermediary and output files.
Clean: Deleted file "final.ESYM".
Clean Warning: File "C:\Program Files\PICC\final.o" doesn't exist.
Clean: Deleted file "final.ERR".
Clean: Done.
Executing: "C:\Program files\Picc\CCSC.exe" +FM "final.c" +DF +LN +T +A +M +Z +Y=9 +EA
*** Error 12 "final.c" Line 21(10,11): Undefined identifier -- setup_adc
*** Error 12 "final.c" Line 22(16,17): Undefined identifier -- setup_adc_ports
*** Error 12 "final.c" Line 23(16,17): Undefined identifier -- set_adc_channel
*** Error 12 "final.c" Line 26(8,9): Undefined identifier -- round
4 Errors, 0 Warnings.
Build Failed.
Halting build on first failure as requested.
BUILD FAILED: Thu Apr 26 00:11:19 2012
Note the setup errors and the round error yet math.h is included.
When I change to #include <16F877A.h>, No errors except the round error. I am not supposed to use 16F877A though. Only 16F628 is available for me. Someone kindly help.
Thanks