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

DS1820 & PIC18F452

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



Joined: 14 Oct 2006
Posts: 27
Location: islamabad,pakistan

View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger

DS1820 & PIC18F452
PostPosted: Fri Mar 30, 2012 11:41 pm     Reply with quote

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
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sat Mar 31, 2012 2:14 am     Reply with quote

Read the CCS forum guide.

It would have helped if you said what the compiler is objecting to, rather than making us work it out.

The setup for the comparators and ADC are different on the two chips.

Read the microchip manuals to figure out the setups you want.

Then look up the new syntax in the 18F452.h file.

Mike
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