zoukankan      html  css  js  c++  java
  • SCM文章9类:外部中断示例程序

    JP3遇见P0口,JP5遇见P3口,P1接受该发光二极管,什么时候P1所有的都是高时,,全亮度发光二极管。因为外部中断0和1用同样的方法。这里只是外部中断0计划。

    #include<reg51.h>
    /*
    * 
    *
    */
    #define uchar unsigned char
    uchar smg[10] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
    void smgLight();
    void delay();
    void initInt0();
    void main()
    {
    	initInt0();
    	while(1)
    	{
    	 	smgLight();
    	}
    	
    }
    
    //
    void outerInterrupt() interrupt 0
    {
    	//
    	int k;
    	for(k=0; k<10; k++)
    	{
    	 	P1 = 0x00;
    		delay();
    		P1 = 0xff;
    		delay();
    	}		
    }
    //
    void initInt0()
    {
    	//ÉèÖÃÍⲿÖжϵĴ¥·¢·½Ê½,µÍµçƽ´¥·¢
    	IT0 = 0;
    	//¿ªÔÊÐíλ
    	EX0 = 1;
    	EA = 1;
    
    }
    //
    void smgLight()
    {
    	int k;
    	for(k = 0; k < 10; k++)
    		{
    			P0 = smg[k];
    			delay();		
    		}	
    }
    //
    void delay()
    {
    	int i,j;
    	for(i = 10000; i > 0; i--)
    		for(j = 10; j > 0; j--);
    }
    写外部中断程序步骤。:

    1、设置外部中断触发方式,进入低电平触发和下降沿

    2、设置外部中断源同意

    3、打开CPU总的同意比特

    4、设置优先级,这可以省略

    5、写中断服务程序,你想实现的功能是什么,需要注意的是声明不需要。你并不需要调用。没有回报值

  • 相关阅读:
    c++学习记录(七)
    c++学习记录(六)
    c++学习记录(五)
    c++学习记录(四)
    2020面向对象寒假作业(二)
    2020面向对象寒假作业(二)
    HTML学习记录(一)
    我罗斯方块
    我罗斯
    面向对象程序设计3
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/5027128.html
Copyright © 2011-2022 走看看