ihsanbu
Joined: 14 Oct 2006 Posts: 27 Location: islamabad,pakistan
|
DS1820 & PIC18F452 |
Posted: Fri Mar 30, 2012 11:41 pm |
|
|
Hi All
I connect ccs forum after long time.
I am working on temperature control system mini project. Hardware is ready but I face the following problem:
1- I want use this code for PIC18f452 micro.
The code is:
Code: |
////////////////////////////////////////////////////
// temperature control system demos //////
// /////
//////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//#include <18F452.h>
//#device adc=10
//#device *=16
//#device adc=10
//#fuses HS,NOWDT,NOPROTECT,NOLVP
//#use delay(clock=4000000)
//#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
//////////////////////////decleard function//////////////////////////////////////
//#include <lcd.c>
#include <16F877A.h>
#device *=16
#device adc=8
#FUSES NOWDT, HS, PUT, NOPROTECT, NODEBUG, BROWNOUT, NOLVP, NOCPD, NOWRT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include<1wire.c>
#include<lcd.c>
//#include <kbd.c>
#include<ds1820.c>
void main()
{
float temperature;
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(VREF_LOW|-2);
lcd_init();
lcd_putc("\f");
while (1)
{
temperature = ds1820_read();
lcd_gotoxy(1,1);
printf(lcd_putc,"TEMP: %3.1f ", temperature);
lcd_putc(223);
lcd_putc("C ");
lcd_gotoxy(1,2);
if(temperature >= 29.0)
printf(lcd_putc,"Hot! ");
//output_high(PIN_C0); // red led 'ON'
//output_low(PIN_C1); // yellow led off
//output_low(PIN_C2); // led off.
//output_high(PIN_C3); // disable WPL relay
else if( temperature >= 20 && temperature < 29.0)
printf(lcd_putc,"Comfort!");
//output_low(PIN_C0); // red led 'ON'
//output_high(PIN_C2); // yellow led off
//output_low(PIN_C2); // led off.
else
printf(lcd_putc,"Cold! ");
// output_low(PIN_C0); // red led 'ON'
//output_low(PIN_C2); // yellow led off
//output_high(PIN_C2); // led off.
}
}
|
Using PIC16F877a its working well but I have PIC18F452 micro chip now.
So how I can do this ? Using above given pic18f452 it will give error message.
Thank you in advance. _________________ ihsan ullah khan
Embedded Designer Since 2003 |
|