Embedded C

I just attended a three day workshop on Microcontrollers and embedded C programming. The workshop was organised by IEEE Students Branch of my institute and professionals from Eureka Electrosoft Solutions Pvt Ltd were invited to deliver the workshop. It was an excellent learning experience, trying to program an Atmel 89C52 microcontroller using embedded C using the Keil Compiler. We also interfaced LCDs, stepmotors and Analog to Digital converter with the microcontroller. Here is my first embedded C program….


#include
#include
#include

void move(unsigned char x)
{
P1=255-pow(2,x);
}

void ms_delay(unsigned char del)
{
unsigned char dt;

while(del>0)
{
for(dt=0; dt<=160; dt++)
nop();
del—;
}

}

void secdelay(unsigned char del)
{


while(del>0)
{
ms_delay(250);
ms_delay(250);
ms_delay(250);
ms_delay(250);
del—;
}

}

void main()
{

while(1)
{

char i;
for(i=7;i>0;i—)
{
move(i);
secdelay(2);
}
for(i=0;i<7;i++)
{
move(i);
secdelay(2);
}

}

}


A simple program in which 8 LEDs are connected to the IC and they blink one after another and back repetitively. It was my first exposure to hardware programming and robotics and really it has impressed me.