[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
(一)中断
(二)定时器,计数器中断
TL0低八位先进行存储,达到0XF,向上进一,直到高低八位都满时就可以产生中断或者控制TF0口。
(1).
TMOD低四位控制T0,高四位控制T1。
GATE:(门控位)
(2)控制寄存器TCON:(低四位控制外部中断,高四位控制计数器启动和中断申请)
(3)定时器的四种工作方式:
定时器开启工作原理:
四种工作方式:(机器周期(脉冲)和T0引脚来绝定电路触发)
区别在于TH0和TL0的位数和输出)
常用1和2
1.
2.用于比较精确的脉冲信号发射器:
3.
程序化步奏:
计算:初值==2^n-N(公式要根据你使用那种方式0.1.2.3四个方式),例如(65535-1000+1),N=1000就是1ms/1us=1000,要想溢出要达到65536,所以定时一毫秒就是初值64536=FC18H(十六进制)
(三)定时器中断:
定时器操作代码:
#include"reg52.h" typedef signed char int8; typedef signed int int16; typedef
signed long int32; typedef unsigned char uint8; //字符型 typedef unsigned int
uint16; typedef unsigned long uint32; sbit led=P2^0; //D1
//***《此函数需要对应以上笔记进行熟悉识别》***// void Time0Init () {
//或运算相当于TMOD=TMOD||0X01,只要有一个为一就为一 TMOD |=0X01; //定时计数选择,工作方式选择,门控位条件 TH0=0XFC;
//定时器初值FC18H,定时一毫秒 TL0=0X18; ET0 =1; //定时器控制中断允许位 EA =1; //总开关 TR0 =1; //启动定时计数器
} //无需定时器函数,因为我们需要用定时器进行计时 //void delay(uint16 x_ms) //延时毫秒 //{ // uint16 i, j;
// for (i = x_ms; i > 0; i--) // for (j = 114; j > 0; j--); //} void Time0()
interrupt0 { static uint16 i; //1秒=1000毫秒 TH0=0XFC; //TH和TL每执行一次,耗时1毫秒 TL0=0X18;
i++; if(i==1000) //所以i要累计到1000 { led=~led; } } void main() { Time0Init(); while
(1); }