89s52 C Program

Topics: Source code, C, Programming language Pages: 4 (1000 words) Published: April 20, 2013
Simple C program for 89S52
Here is a very simple but complete example program to blink a LED. Actually it is the source code of the example project that we are going to construct in the next part of the tutorial, but for now it is important to concentrate on the programming to summarize the notions discussed above. -------------------------------------------------

#include <REGX52.h>
-------------------------------------------------
#include <math.h>
-------------------------------------------------

-------------------------------------------------
delay(unsigned int y){
-------------------------------------------------
unsigned int i;
-------------------------------------------------
for(i=0;i<y;i++){;}
-------------------------------------------------
}
-------------------------------------------------

-------------------------------------------------
main(){
-------------------------------------------------
while(1){
-------------------------------------------------
delay(30000);
-------------------------------------------------
P1_0 = 0;
-------------------------------------------------
delay(30000);
-------------------------------------------------
P1_0 = 1;
-------------------------------------------------
}
-------------------------------------------------
}
After including basic headers for the SFR definitions of the 8952 microcontroller (REGX52.h) and for mathematical functions (math.h), a function named ‘delay’ is created, which is simple a function to create a delay controlled via the parameter ‘y’. Then comes the main function, with an infinite loop (the condition for that loop to remain will always be...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • C++ Programs Essay
  • Essay on C Program
  • C Program Essay
  • Simple Program for Student C++ Essay
  • Odd-Even Program C++ Essay
  • Pythagorean Theorem and C++ Program Essay
  • Shortest C Crashing Program Essay
  • Essay on ceaser cipher program in c++

Become a StudyMode Member

Sign Up - It's Free