MCU / 8 /8.c
KeLe-open-code's picture
Publish reviewed course materials
37e076f verified
Raw History Blame Contribute Delete
556 Bytes
#include <REG51.H>
unsigned char count = 0;
void timer0(void) interrupt 1
{
TH0 = (65536UL - 50000) / 256;
TL0 = (65536UL - 50000) % 256;
count++;
if (count == 20)
{
count = 0;
P2 = ~P2;
}
}
void main(void)
{
P2 = 240;
TMOD = 1;
TH0 = (65536UL - 50000) / 256;
TL0 = (65536UL - 50000) % 256;
ET0 = 1;
EA = 1;
TR0 = 1;
while (1);
}