#include <stdio.h>
#include <reg51.h>

unsigned char calc_checksum (
  unsigned char *start_addr,
  unsigned int len)
{
	unsigned char checksum = 0;

	for (; len > 0; len--, start_addr++)
      {
  		checksum += *start_addr;
      }

	return (checksum);
}

/*---------------------------------------------------------
Checksum RANGE = 0x0000-0x3FFE
Checksum BYTE  = 0x3FFF
---------------------------------------------------------*/
void main (void)
{
	while (1)
	{
		unsigned char checksum = 0;
		unsigned char i = 0;
		P0 = 0;

	      SCON  = 0x50;		    /* SCON: mode 1, 8-bit UART, enable rcvr      */
	      TMOD |= 0x20;               /* TMOD: timer 1, mode 2, 8-bit reload        */
	      TH1   = 221;                /* TH1:  reload value for 1200 baud @ 16MHz   */
	      TR1   = 1;                  /* TR1:  timer 1 run                          */
	      TI    = 1;                  /* TI:   set TI to send first char of UART    */

		checksum = calc_checksum ((unsigned char code *) 0, 0x0040);

		P0 = 1;
		P1 = checksum;
	}
}


<div align="center"><br /><script type="text/javascript"><!--
google_ad_client = "pub-7293844627074885";
//468x60, Created at 07. 11. 25
google_ad_slot = "8619794253";
google_ad_width = 468;
google_ad_height = 60;
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script><br />&nbsp;</div>