mikroc 8.2 multible source file

Discussion in 'Embedded Systems and Microcontrollers' started by walid el masry, May 8, 2011.

  1. walid el masry

    Thread Starter Active Member

    Mar 31, 2009
    132
    0
    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

    Code ( (Unknown Language)):
    1.  
    2. // main code
    3. // inti & set & clr are source files to be included
    4. void main(){
    5.  inti();
    6.  while(1){
    7.   set();
    8.   clr();
    9.  }
    10. }
    11.  
    Code ( (Unknown Language)):
    1.  
    2. void inti(){
    3.  TRISB = 0x00;
    4.  PORTB = 0x00;
    5. }
    6.  
    Code ( (Unknown Language)):
    1.  
    2. void set(){
    3.  PORTB.f0 = 1;
    4.  delay_ms(1000);
    5. }
    6.  
    Code ( (Unknown Language)):
    1.  
    2. void clr(){
    3.  PORTB.f0 = 0;
    4.  delay_ms(1000);
    5. }
    6.  
     
    Last edited: May 8, 2011
Loading...