jay_3189
Banned
- Joined
- Sep 19, 2013
- Messages
- 104
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 16
- Location
- Ahmedabad
- Activity points
- 0
I am using 89c51 controller and crystal frequency of 11.0592mhz and using c language to create delay loop. I wanted to know that delay_us(), delay_ms() and delay_sec() are by default function of this controller or I have to create it on my own way.
if its by default then ow could I use it and if not then please verify bellowed one.. is that right one.
and can I use this loop delay for using I2C communication for DS1307 RTC.
if its by default then ow could I use it and if not then please verify bellowed one.. is that right one.
and can I use this loop delay for using I2C communication for DS1307 RTC.
HTML:
/*It genarates a approximate delay of 10us for each count,
if 5000 is passed as the argument then it generates a delay of apprx 50ms.*/
void delay_us(unsigned int us_count)
{
while(us_count!=0)
{
us_count--;
}
}
/*It genarates a approximate delay of 1ms for each count,
if 1000 is passed as the argument then it generates delay of apprx 1000ms(1sec)*/
void delay_ms(unsigned int ms_count)
{
while(ms_count!=0)
{
delay_us(112); //delay_us is called to generate 1ms delay
ms_count--;
}
}
/*It genarates a approximate delay of 1sec for each count,
if 10 is passed as the argument then it generates delay of apprx 10sec
note: A max of 255 sec delay can be generated using this function.*/
void delay_sec(unsigned char sec_count)
{
while(sec_count!=0)
{
delay_ms(1000); //delay_ms is called to generate 1sec delay
sec_count--;
}
}