/*
*******************************************************************************************************************
*												BLINK LED DEMO
* Description:  The first demo program for AT89S52-gLCD-STK1 board to blink an LED at ~10Hz by software delay
* File:			cd:\src\chp2\src2_1\main.c
* Software:		Keil C (C51) compiler, Eval version 7.09 under uVision2 IDE v2.40
* Programmer: 	John Leung, TechToys Co. (www.TechToys.com.hk)
* Hardware:		AT89S52-gLCD-STK1, with Atmel 89S52, 11.0592 MHz crystal
* Date:			24th May 2006
* Version:		1.0
* Programmer:	John Leung
*
* 												All Rights Reserved
*
*******************************************************************************************************************
*/
#include <reg52.h>

#define ON 	0
#define OFF	1

//Pin definition
sbit LED = P2^0;

// Function prototype
void DelayMs(unsigned int msec);



/*
*******************************************************************************************************************
*											MILLI-SECOND SOFTWARE DELAY ROUTINE
* Function:	This function makes software delay in milli-sec, adjusted for a crystal freq. 11.0592MHz for AT89S52
* Argument:	'msec'		amount of delay in milli-sec
* Return:	none
*
* Note:		
*******************************************************************************************************************
*/
void DelayMs(unsigned int msec)
{
	unsigned int x,y;

	for(x=0; x<=msec;x++)
		{
			for(y=0;y<=110;y++);
		}
}

// Main 
// Simple demo program just to blink an LED at a rate of ~10Hz
void main(void)
{
	for(;;)
		{
			LED = ON;
			DelayMs(50);
			LED = OFF;
			DelayMs(50);
		}
}
