This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to divide my complete c code into small c codes.

i have written the C code complied it with 0 error and 0 warnings.

now how can i divide this codes into small c codes in same project.

please help me as i am new to embedded world

Parents
  • This has nothing specifically to do with embedded - nor even with any specific programming language!
    This is a basic programming principle.

    You should look for functions (and associated data) that have something in common, and group them into a "module" (ie, a .c source file) of their own.

    How well a group of functions goes together is known as "Cohesion".
    There are several types of cohesion; eg,

    Functional Cohesion - things which go together to perform a single, well-defined function within the system; eg, a UART driver.

    Temporal Cohesion - things which happen at the same time; eg, initialisation.

    Coincidental Cohesion - things which really don't have anything in common at all, and are just grouped together because you couldn't think of anywhere else to put them!

    See: en.wikipedia.org/.../Cohesion_(computer_science)

    For the specifics of how to do this in 'C', see your 'C' textbook, and take a look at c-faq.com/.../decldef.html

    Also take a look at the examples included in your C51 installation (also available on this website) - I think pretty much all of them contain more than 1 source file...

Reply
  • This has nothing specifically to do with embedded - nor even with any specific programming language!
    This is a basic programming principle.

    You should look for functions (and associated data) that have something in common, and group them into a "module" (ie, a .c source file) of their own.

    How well a group of functions goes together is known as "Cohesion".
    There are several types of cohesion; eg,

    Functional Cohesion - things which go together to perform a single, well-defined function within the system; eg, a UART driver.

    Temporal Cohesion - things which happen at the same time; eg, initialisation.

    Coincidental Cohesion - things which really don't have anything in common at all, and are just grouped together because you couldn't think of anywhere else to put them!

    See: en.wikipedia.org/.../Cohesion_(computer_science)

    For the specifics of how to do this in 'C', see your 'C' textbook, and take a look at c-faq.com/.../decldef.html

    Also take a look at the examples included in your C51 installation (also available on this website) - I think pretty much all of them contain more than 1 source file...

Children