top of page

microcontroller - PROGRAM FLOW

Before programming a micro-controller, one should have basic concept on flow-chart and algorithm.

While programming a micro-controller, the following order of sequence is followed in general.   A small deviation may be observed, which depends on the habit of the person, who is programming and micro-controller programming IDE (integrated Development Environment) software, which is used for programming and compiling.  Some IDEs support the option to directly upload/write the binary code to MCU.

  1. comments/remarks and GNU about the program

  2. Declaration of frequency of the MCU clock.  Sometimes optional, which may be declared in the settings/preferences.

  3. include or import the libraries required.  Some libraries may be included by default, which depends on the IDE.

  4. Declare the global variables and initial values as required for the program

  5. Declare the classes or structures, if any ( normally used for OOPS programming ).

  6. Declare and write required functions / methods required.

  7. Declare ONCE, the ports as input/Output/Analog/Communication and their direction of data flow, like from MCU (Output) , to MCU (Input) etc. The syntax may vary for each type of MCU.  Some Variables and Functions, which are defined earlier, may be called for initial setup.

  8.  Write a continuous loop for actual requirement, which may have functions are called or input/Output/Analog/Communication ports are used to communicate with the external world of the MCU.  |This is the main loop, which uses the required logic and sequence of operations to obtain required results.

The actual syntax and coding is depending on the programming language, but the logic is same for all the programming languages.

bottom of page