/*
developed by S4silver
license type - open source
created on - 11/12/2014
modified on - 11/14/2014
modification details - refactored
developer - Frank Hust Jincson
contact mail id - silverembeddedsolutions@gmail.com
web link - http://s4silver.blogspot.in/p/programmers-colony.html
*/
#include<reg51.h>
sbit led = P1^0; // LED connected to 1st pin of port P1
void delay();
main()
{
unsigned int i;
while(1)
{
led=~led; // Toggle LED
for(i=0;i<1;i++)
delay(); // Call delay
}
}
void delay() // Delay generation using Timer 0 mode 1
{
TMOD = 0x01; // Mode1 of Timer0
TH0= 0xFF; // FC66 evaluated hex value for 1millisecond delay
TL0 = 0xFF; //0x66;
TR0 = 1; // Start Timer
while(TF0 == 0); // Using polling method
TR0 = 0; // Stop Timer
TF0 = 0; // Clear flag
}
/*
65535 - (12*10^6 * 1*10^-3) / 12
65535-1000
64535
*/
No comments:
Post a Comment