首页 > k8新闻中心 > 公司新闻

凯发k8官网|C51: INT0

发布时间:2025-10-15 17:01:28    次浏览

//P3.0输出脉冲,用INT0记录脉冲个数,//用P1输出脉冲个数//外部连接:P3.0与INT0输入端P3.2连接。#includereg52.hsbitout=P3^0;voiddelay(){unsignedinti;for(i=0;i20000;i++);}unsigned int counter=0;void main(){//INT0 设置EA=1; //CPU 中断允许EX0=1; //INT0 中断允许IT0=1; //下降缘触发//while(1){out=1;delay();delay();out=0;delay();delay();}while(1);}//INT0 中断程序void int0fun() interrupt0{counter++;if(counter==256)counter=0;elseP1=255-counter;}原文链接:http://www.eeworld.com.cn/mcu/article_2016101430471.html