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

need help compiling c into hex file!!!

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







need help compiling c into hex file!!!
PostPosted: Mon Jan 29, 2007 4:53 am     Reply with quote

i am really a beginner at programming a mcu. i have already wrote the c code to program my PIC16F877A microcontroller, but i can't figure out how to convert this c code to its hex counterpart.

i have downloaded a demo version of the ccs c compiler which needed an internet connection to operate. i compiles the program and it stated no error.

now what is the next step. Please help me!!!!!
Mark



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

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

PostPosted: Mon Jan 29, 2007 7:05 am     Reply with quote

Look in the project directory and you will find the hex file if it did indeed compile without errors.
tom5467
Guest







PostPosted: Tue Jan 30, 2007 8:15 am     Reply with quote

the ccs c compiler did reply that it had no errors, but i doubt that it had none. see my project is to create a fire protection system which consists of a main and remote unit, both with PIC16F877A. The main unit has four analog inputs to sense presence of fire hazard and three led outputs for warning purposes. one o/p activates a solenoid while still another o/p is sent to other PIC.

this is what the code looks like for the main unit_:
----------------------------------------------------------------
#include <16F877A.h>

#device *=16 ADC=10

#fuses HS
#fuses NOWDT
#fuses NOPROTECT
#fuses NOLVP
#fuses NODEBUG
#fuses NOPUT
#fuses NOBROWNOUT

#use delay(clock=4000000)

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

#define MY_TRISA 0b11111111
#define MY_TRISB 0b11111111
#define MY_TRISC 0b00000000
#define MY_TRISD 0b00000000

#define FOREVER 1


#define TEMP_LED PIN_C0 // out PIN 15
#define SMOKE_LED PIN_C1 // out PIN 16
#define LDR_LED PIN_C2 // out PIN 17

#define REMOTE_IND PIN_C6 // out PIN 25

#define FIRE_EXT_ACTIVATE PIN_D6 // out PIN 29

void initADC(void);

#pragma zero_ram // Clears all of the ram not used by the program

void main( void)
{
int16 ADC_0;
int16 ADC_1;
int16 ADC_2;
int16 ADC_3;
int16 temp;
int16 smoke;
int16 LDR;
int16 test;
ADC_0 = 0;
ADC_1 = 0;
ADC_2 = 0;
ADC_3 = 0;
temp = 665;
smoke = 1007.616;
LDR = 716.8;
test = 40.96;


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

Set_Tris_A(MY_TRISA); // Port A's I/O
Set_Tris_B(MY_TRISB); // Port B's I/O
Set_Tris_C(MY_TRISC); // Port C's I/O
Set_Tris_D(MY_TRISD); // Port D's I/O

initADC();

while(FOREVER)
{
// beginning of testing of the lights
delay_us(50);
set_adc_channel( 3 );
delay_us(10);
ADC_3 = read_adc(); // Read in the value of the ADC
delay_us(50000);

if (ADC_3 > test)
{
output_high(TEMP_LED);
output_high(SMOKE_LED);
output_high(LDR_LED);
output_high(REMOTE_IND);
}
else
{
output_low(TEMP_LED);
output_low(SMOKE_LED);
output_low(LDR_LED);
output_low(REMOTE_IND);
}


//beginning of temperature sensing
delay_us(50);
set_adc_channel( 0 );
delay_us(10);
ADC_0 = read_adc(); // Read in the value of the ADC
delay_us(50000);

if (ADC_0 > temp)
{

set_adc_channel( 1 );
delay_us(10);
ADC_1 = read_adc(); // Read in the value of the ADC
delay_us(50000);


if (ADC_1 > smoke)
{
output_high(SMOKE_LED);
output_high(FIRE_EXT_ACTIVATE);
output_high(TEMP_LED);
output_high(REMOTE_IND);
}
else
{
output_high(TEMP_LED);
output_high(REMOTE_IND);
}

}
//beginning of smoke sensing

else
{
output_low(TEMP_LED);
output_low(REMOTE_IND);
output_low(SMOKE_LED);
output_low(FIRE_EXT_ACTIVATE);

delay_ms(100);
set_adc_channel( 1 );
delay_us(10);
ADC_1 = read_adc(); // Read in the value of the ADC
delay_us(50000);

if (ADC_1 > smoke)
{
output_high(SMOKE_LED);
output_high(REMOTE_IND);
}
//beginning of light sensing

else
{
output_low(SMOKE_LED);
output_low(REMOTE_IND);

delay_ms(100);
set_adc_channel( 2 );
delay_us(10);
ADC_2 = read_adc(); // Read in the value of the ADC
delay_us(50000);

if ( ADC_2 < LDR )
{
output_high(LDR_LED);
//output_high(REMOTE_IND);
}

else
{
output_low(LDR_LED);
//output_low(REMOTE_IND);
}
}

}
}
}
}

// Purpose: Initializes ADC
// Precondition: None
// Postcondition: ADC is configured

void initADC(void)
{
setup_adc_ports(ALL_ANALOG); //
setup_adc(ADC_CLOCK_INTERNAL);
}

---------------------------------------------------------------

thankx for being patient enough for reading this!!! please let me know it u see any errors.[/code]
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