Computer Science, asked by Sharathts, 3 months ago

A switch is connected to pen p1.2 write a 8051 c program to monitor sw and create the following frequency on pin p1.7 sw=0:500HZ, sw=1:750HZ, use timer 0, mode 1 for both of then ​

Answers

Answered by kumarsachin9262
0

Answer:

a 8051 c program to monitor sw and create the following frequency on pin p1.7 sw=0:500HZ, sw=1:750HZ

Answered by dreamrob
3

Program:

#include<reg51.h>

sbit mybit = P1^5;

sbit SW = P1^7;

void Delay(unsigned char);

void main(void)

{

  SW = 1;

  while(1)

  {

     mybit = ~mybit;

     if(SW == 0)

        Delay(0);

     else

        Delay(1);

  }

}

void Delay(unsigned char c)

{

  TMOD = 0x01;

  if(c == 0)

  {

     TL0 = 0x67;

     TH0 = 0xFC;

  }

  else

  {

     TL0 = 0x9A;

     TH0 = 0xFD;

  }

  TR0 = 1;

  while(TF0 == 0);

  TR0 = 0;

  TF0 = 0;

}

Similar questions