Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

Project Request

Return
iverson nair
iverson

posted on 2013/05/20 06:56:58 AM CEST

Measurement

how to link two projects

hi im new at programming. i have compilled two different sorce codes and want to use one chip to run both programms.
when i build them in mikroc pro the software builds but only the first program works. i have test the programs buy building the individualy and they work, but if put together i have a problem . can any one please assist me



//*my first project**************************************************************
//* AUTHOR: IVERSON NAIR
//* DATE : 19/05/2013
//* PROJECT: pic 16f887, with lm35 ; button on ports
//*


unsigned int adc_value;
long temp;
char value [15];
char *degs = "00.00";
void main() {
char TEST = 5; // Constant TEST = 5
enum outputs {RELAY = 3}; // Constant RELAY = 3


float result;
unsigned char lcd_value[15];
int temp_flag=0;
const low_temp=25.00;
const high_temp=26.00;

TRISC7_bit=0;
ADC_Init();
RC7_bit=0;


ADCON0 = 0b01010000; // Fosc/32, RA2 input
ADCON1 = 0b10000001; // Ra3 = Vref, all analog = 2.5V
TRISB = 0x00; // PORTB All Outputs

TRISA = 0xFF; // PORTA All Inputs

while(1) {
result = ADC_Read(2);
temp = result/2.048;


FloatToStr(temp,lcd_value);




if(temp<low_temp){
RC7_bit=1;
temp_flag=1;
}
else if (temp>high_temp){
RC7_bit=0;
temp_flag=0;
}
else if (temp<=high_temp && temp>=low_temp){
if(temp_flag==1){
RC7_bit=1;
}
else{
RC7_bit=0;
}
}
else {
RC7_bit=0;

}
}
}
void main1() {

char TEST = 5; // Constant TEST = 5
enum outputs {RELAY = 3}; // Constant RELAY = 3



ANSEL = 0;
ANSELH = 0;
PORTB = 0 ; // Reset port B
TRISB= 0xFF; // All portb pins are configured as inputs
PORTD = 0; // Reset port D
TRISD = 0b11110011; // Pin RD3 is configured as an output, while the rest are
// configured as inputs


do {

if (Button(&PORTB,0,1,1)) // Does the number in timer match constant TEST?
(PORTD.RELAY = 1); // Numbers match. Set the RD3 bit (output RELAY)


if (Button(&PORTB,1,1,1)) // Does the number in timer match constant TEST?
(PORTD.RELAY = 1); // Numbers match. Set the RD3 bit (output RELAY)


if (Button(&PORTB,5,1,1)) // Does the number in timer match constant TEST?
(PORTD.RD2 = 1); // Numbers match. Set the RD2 bit (output DBW)

}
while (1); // Remain in endless loop
}