Write a program to create a frequency of 2 HZ on pin PORTB1
-Write a program to create a frequency of 2 HZ on pin PORTB.1. Use Timer to create the delay. \" pleae use C code\"
Solution
Given delay is very unpractical, i think it should be 2KHz.
any way for creating a delay using Timer we need following equation for calculating the initial count in case of 16 bit timer count.
Initial count(in decimal)= (65536- (delay*clock frequency)/12)
then change decimal value to hex value . This is your initial count that is to be given into TH0 and TL0
#include <reg51.h>
void T0Delay(void);
void main(void)
{
while(1)
{
b.1=0x00
T0Delay();
b.1=0x01;
T0Delay();
}
}
void T0Delay()
{
TMOD = 0X01;
TL0=0X06;
TH0=0XFF;
TR0=1;
while(TF0==0);
TR0=0;
TF0=0;
}
