hi
is it possible to separate the source code in c language into multiple source code files and include all of source code files in the same project so that i can use methods in each file without declaring all methods in the same main file to reduce the amount of code written in the main code file
as example for that i would like to blink a led so there is 4 steps for that
1- initialize the output pin
2- set bit and wait for suitable time
3- clear bit and wait for suitable time
4- put step 2 & 3 in infinite loop
is it possible to separate the source code in c language into multiple source code files and include all of source code files in the same project so that i can use methods in each file without declaring all methods in the same main file to reduce the amount of code written in the main code file
as example for that i would like to blink a led so there is 4 steps for that
1- initialize the output pin
2- set bit and wait for suitable time
3- clear bit and wait for suitable time
4- put step 2 & 3 in infinite loop
Rich (BB code):
// main code
// inti & set & clr are source files to be included
void main(){
inti();
while(1){
set();
clr();
}
}
Rich (BB code):
void inti(){
TRISB = 0x00;
PORTB = 0x00;
}
Rich (BB code):
void set(){
PORTB.f0 = 1;
delay_ms(1000);
}
Rich (BB code):
void clr(){
PORTB.f0 = 0;
delay_ms(1000);
}
Last edited: