Thursday, October 19, 2017

Basic of Embedded C Program Example Circuit Based Microcontroller AT89S52

Eltronicschool. - When we discuss about the basic of embedded C program, it will show us that the basic of an extension to the standard C programming language with additional features completed like addressing I/O, multiple addressing and fix-point arithmetic and others.

In here, we will show you the example of the basic C embedded C program with circuit based microcontroller 8051 type AT89S52 that popular in basic microcontroller.


Image Courtesy of


Accordingly Electronics Hub site that also published this example of basic embedded C program for microcontroller AT89S52 describe that the following image shows the circuit diagram for the example circuit. It contains an 8051 based Microcontroller (AT89S52) along with its basic components (like RESET Circuit, Oscillator Circuit, etc.) and components for blinking LEDs (LEDs and Resistors).

In order to write the Embedded C Program for the above circuit, we will use the Keil C Compiler. This compiler is a part of the Keil ┬ÁVision IDE. The program is shown below.

#include<reg51.h> // Preprocessor Directive
void delay (int); // Delay Function Declaration

void main(void) // Main Function
P1 = 0x00; 
/* Making PORT1 pins LOW. All the LEDs are OFF.
(P1 is PORT1, as defined in reg51.h) */

while(1) // infinite loop
P1 = 0xFF; // Making PORT1 Pins HIGH i.e. LEDs are ON.
/* Calling Delay function with Function parameter as 1000.
This will cause a delay of 1000mS i.e. 1 second */

P1 = 0x00; // Making PORT1 Pins LOW i.e. LEDs are OFF.

void delay (int d) // Delay Function Definition
unsigned int i=0; // Local Variable. Accessible only in this function.

/* This following step is responsible for causing delay of 1000mS (or as per the value entered while calling the delay function) */

for(i=250;i>0;i – -);
for(i=248;i>0;i – -);


Thank you for your coming here in site, we hope the article above will help you to know more about your an electronic circuit design and software in this time, etc. Please comment here when you want to share and other. Thank you.


Post a Comment

Thank's for your reading in this article, please don't forget to comment.