Saturday, December 27, 2008

Programming 8051 in C

* open a text editor like notepad. type a simple code like

#include <8051.h>
void main(void)
{
int i=1;
P1=0; /* clear PORT1 of the MCS51 - P1.7 used as LED output */
for(;;)
{
//P1_7=!(P1_7); /* toggle P1.7*/
P1=
for(i=1;i<15000;i++);
/* idle loop - eat CPU time */
}
}

*get sdcc, install it and setpath.

*run with
sdcc porttest.c

* convert ihx into hex by
packihx output.hex

*simulate using EdSim51.

ref http://www.final-memory.org/?cat=36