Skip to content

Instantly share code, notes, and snippets.

@SaheblalBagwan
Created August 23, 2016 05:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save SaheblalBagwan/b8fa48ee29693f2a42a7338f0f103a80 to your computer and use it in GitHub Desktop.
Save SaheblalBagwan/b8fa48ee29693f2a42a7338f0f103a80 to your computer and use it in GitHub Desktop.
#include<reg51.h>
sbit LED = P0^0;
void timer0_isr() interrupt 1
{
LED =! LED; // Toggle the LED pin,
//Note Timer value is not reloaded, It is automatically taken care
}
void main()
{
TMOD = 0x02; //Timer0 mode 2
TH0 = 0X1A; //Load the timer value
TR0 = 1; //turn ON Timer zero
ET0 = 1; //Enable TImer0 Interrupt
EA = 1; //Enable Global Interrupt bit
while(1)
{
// Do nothing
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment