51单片机学习笔记———6.中断法配置定时器
51单片机学习笔记———6.中断法配置定时器
#include<reg52.h>
sbit LED P0^4;
void main()
{EA = 1;//打开总中断TMOD&=0xFC;TMOD|=0x01;TH0 = (65535-2000)/256;//定时2msTL0 = (65535-2000)/%256;ET0 = 1;TR0 = 1;while(1){...}void interruptTime() interrupt 1{static unsigned int n = 0;TH0 = (65535-2000)/256;TL0 = (65535-2000)%256;n++;if(n>=1000){n = 0;LED =!LED;}}
}
51单片机学习笔记———6.中断法配置定时器
51单片机学习笔记———6.中断法配置定时器
#include<reg52.h>
sbit LED P0^4;
void main()
{EA = 1;//打开总中断TMOD&=0xFC;TMOD|=0x01;TH0 = (65535-2000)/256;//定时2msTL0 = (65535-2000)/%256;ET0 = 1;TR0 = 1;while(1){...}void interruptTime() interrupt 1{static unsigned int n = 0;TH0 = (65535-2000)/256;TL0 = (65535-2000)%256;n++;if(n>=1000){n = 0;LED =!LED;}}
}
发布评论