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

To find the test.c, Comiler.h, Globals.h, and Misc.c files

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



Joined: 26 May 2008
Posts: 1
Location: addis ababa,ethiopia

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

To find the test.c, Comiler.h, Globals.h, and Misc.c files
PostPosted: Sun Jun 01, 2008 3:12 am     Reply with quote

How can I find different files, i.e. test.c, comiler.h, globals.h, and Misc.c from this code so that I can run it easily on pic c compiler
Tx!


Code:
#device *=16 ADC=10

#use delay(clock=20000000)

#use fast_io(A)
#use fast_io(B)
#use fast_io(C)
#use fast_io(D)

int16 photoTRIGGER = 635; // <310mV preset value for light switch
int16 minTEMP = 1372; // 670mV preset min sample value for T (30C)
int16 maxTEMP = 1597; // 780mV preset max sample value for T (38C)
int16 minHUMID = 614; // 350mV preset min value for H (30%RH)
int16 maxHUMID = 1065; // 520mV preset max value for H (52%RH)

int8 photoCOND;
int8 minTempCOND;
int8 maxTempCOND;
int8 minHumidCOND;
int8 maxHumidCOND;

// End Preprocessor Directives

#include "Include\Compiler.h"
#include "Include\Globals.h"
#include "Include\Misc.c"

/******************************************************************************\
*                                                                              *
*                    F U N C T I O N   P R O T O T Y P E S                     *
*                                                                              *
\******************************************************************************/

void initTimers( void);
void initADC( void);
void timer1ISR( void);
void timer2ISR( void);    // ISR does not stand for Illinois Street Residence


/******************************************************************************\
*                                                                              *
*                            M A I N   R O U T I N E                           *
*                                                                              *
\******************************************************************************/
#pragma zero_ram                     // Interesting command ....
void main( void)
{
   disable_interrupts(GLOBAL);       // We don't want to be interrupted yet

   delay_ms(500);       // wait for voltages to stablize

   Set_Tris_A(MY_TRISA);    // Port A's I/O
   Set_Tris_B(MY_TRISB);    // Port B's I/O

   delay_ms(50);

   initTimers();
   initADC();
   delay_ms(50);

   while(FOREVER)
   {
      readADC_1();
      readADC_2();
      readADC_3();
   }
}
// End Main Routine


/******************************************************************************\
*                                                                              *
*               S U B - R O U T I N E   I M P L E N T A T I O N S              *
*                                                                              *
\******************************************************************************/


//  Purpose:         Initializes timer interrupts
//  Precondition:    None
//  Postcondition:   Timers and interrupts are enabled
void initTimers(void)
{
   setup_timer_1( T1_INTERNAL | T1_DIV_BY_8 );              // confusing?
   setup_timer_2( T2_DIV_BY_4, 0x20, 2);                    // even more so!
   enable_interrupts(INT_TIMER1);
   enable_interrupts(INT_TIMER2);
   enable_interrupts(GLOBAL);
   timer1Count = 0;
   timer2Count = 0;
   timer3Count = 0;
   timer4Count = 0;
   timer5Count = 0;
}


//  Purpose:         Initializes ADC
//  Precondition:    None
//  Postcondition:   ADC is configured
void initADC(void)
{
   setup_adc(ADC_CLOCK_INTERNAL);
   set_adc_channel( 0 );
   delay_us(10);
}

//End Sub-Routine Implementions

/******************************************************************************\
*                                                                              *
*              I N T E R R U P T   S E R V I C E   R O U T I N E S             *
*                                                                              *
\******************************************************************************/


//  Purpose:         Timer1 ISR
//  Precondition:    initTimers called
//  Postcondition:   Timer1 counter updated
#INT_TIMER1
void Timer1ISR(void)
{
   timer1Count++;
   timer2Count++;
   timer3Count++;
   timer4Count++;
   timer5Count++;
}


#INT_TIMER2
void Timer2ISR(void)
{
   if (timer1Count == 0)
   {
      if ((ADC_1 * 10) < photoTRIGGER)
      {
         output_low(photo_switch);
         photoCOND = 0;
      }
      else if ((ADC_1 * 10) > photoTRIGGER)
      {
         output_high(photo_switch);
         photoCOND = 1;
      }
   }
   else if ((timer1Count > 0) && (timer1Count < 300))
   {
      if (photoCOND == 1)
      {
         output_high(photo_switch);
      }
      else if (photoCOND == 0)
      {
         output_low(photo_switch);
      }
   }
   else if (timer1Count == 300)
   {
      if (photoCOND == 1)
      {
         output_high(photo_switch);
      }
      else if (photoCOND == 0)
      {
         output_low(photo_switch);
      }
      timer1Count = 0;
   }

   if (timer2Count == 0)
   {
      if ((ADC_2 * 10) > maxTEMP)
      {
         output_high(fan_switch);
         maxTempCOND = 1;
      }
      else if ((ADC_2 * 10) < maxTEMP)
      {
         output_low(fan_switch);
         maxTempCOND = 0;
      }
   }
   else if ((timer2Count > 0) && (timer2Count < 300))
   {
      if (maxTempCOND == 1)
      {
         output_high(fan_switch);
      }
      else if (maxTempCOND == 0)
      {
         output_low(fan_switch);
      }
   }
   else if (timer2Count == 300)
   {
      if (maxTempCOND == 1)
      {
         output_high(fan_switch);
      }
      else if (maxTempCOND == 0)
      {
         output_low(fan_switch);
      }
      timer2Count = 0;
   }

   if (timer3Count == 0)
   {
      if ((ADC_2 * 10) < minTEMP)
      {
         output_high(heater_switch);
         minTempCOND = 1;
      }
      else if ((ADC_2 * 10) > minTEMP)
      {
         output_low(heater_switch);
         minTempCOND = 0;
      }
   }
   else if ((timer3Count > 0) && (timer3Count < 300))
   {
      if (minTempCOND == 1)
      {
         output_high(heater_switch);
      }
      else if (minTempCOND == 0)
      {
         output_low(heater_switch);
      }
   }
   else if (timer3Count == 300)
   {
      if (minTempCOND == 1)
      {
         output_high(heater_switch);
      }
      else if (minTempCOND == 0)
      {
         output_low(heater_switch);
      }
      timer3Count = 0;
   }

   if (timer4Count == 0)
   {
      if ((ADC_3 * 10) < minHUMID)
      {
         output_high(mister_switch);
         minHumidCOND = 1;
      }
      else if ((ADC_3 * 10) > minHUMID)
      {
         output_low(mister_switch);
         minHumidCOND = 0;
      }
   }
   else if ((timer4Count > 0) && (timer4Count < 300))
   {
      if (minHumidCOND == 1)
      {
         output_high(mister_switch);
      }
      else if (minHumidCOND == 0)
      {
         output_low(mister_switch);
      }
   }
   else if (timer4Count == 300)
   {
      if (minHumidCOND == 1)
      {
         output_high(mister_switch);
      }
      else if (minHumidCOND == 0)
      {
         output_low(mister_switch);
      }
      timer4Count = 0;
   }

   if (timer5Count == 0)
   {
      if ((ADC_3 * 10) > maxHUMID)
      {
         output_high(dehumid_switch);
         maxHumidCOND = 1;
      }
      else if ((ADC_3 * 10) < maxHUMID)
      {
         output_low(dehumid_switch);
         maxHumidCOND = 0;
      }
   }
   else if ((timer5Count > 0) && (timer5Count < 300))
   {
      if (maxHumidCOND == 1)
      {
         output_high(dehumid_switch);
      }
      else if (maxHumidCOND == 0)
      {
         output_low(dehumid_switch);
      }
   }
   else if (timer5Count == 300)
   {
      if (maxHumidCOND == 1)
      {
         output_high(dehumid_switch);
      }
      else if (maxHumidCOND == 0)
      {
         output_low(dehumid_switch);
      }
      timer5Count = 0;
   }
}
Ttelmah
Guest







PostPosted: Sun Jun 01, 2008 3:09 pm     Reply with quote

From the original author of the code.....
These are _not_ standard CCS files. 'Globals', probably contains definitions of global variables (there are several used in the code, with no definitions present). Misc, would probably contain the code to read the adc (there are three functions being used to do this, that are not standard CCS functions). The code as posted, wouldn't compile, even if these were present, since the processor type definition is missing at the start of the code.
Basically, you will either have to write the code again, from a description of what it is expected to do, or get hold of the source.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 01, 2008 4:26 pm     Reply with quote

Yonas,
Just a little bit of Googling finds this stuff.

First, Google for the filenames, like this:
Quote:
"misc.c" "globals.h" "compiler.h"

The first thing we find is that you have been posting this same
question on other PIC boards, instead of searching for it yourself.

But anyway, we quickly find that these files are used by students
for the ECE445 course at the University of Illinois.
Quote:
courses.ece.uiuc.edu/ece445/projects

By playing around with the URL, we eventually get this page.
https://courses.ece.uiuc.edu/ece445/

Once you've got that, you eventually get to their PIC page.
http://courses.ece.uiuc.edu/ece445/wiki/?n=Topics.PicProgramming
Down at the bottom in "The Code" section, they've got all those
include files zipped up for you, ready to download.
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