打印
[DemoCode下载]

外部中断的使用方法

[复制链接]
643|6
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
捉虫天师|  楼主 | 2019-8-31 23:49 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* Copyright(c) 2019 Nuvoton Technology Corp. All rights reserved.                                         */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/

//***********************************************************************************************************
//  Website: http://www.nuvoton.com
//  E-Mail : MicroC-8bit@nuvoton.com
//***********************************************************************************************************

#include "ML51.h"

/**
* [url=home.php?mod=space&uid=247401]@brief[/url]              External pin interrupt INT0 demo
* @param       None
* [url=home.php?mod=space&uid=266161]@return[/url]      None
* [url=home.php?mod=space&uid=1543424]@Details[/url]     None
*/


void INT0_ISR(void) interrupt 0          // Vector [url=home.php?mod=space&uid=72445]@[/url]  0x03
{
/* Clear INT0 interrupt flag */
                clr_TCON_IE0;
                printf ("\n INT0 interrupt");
}


void main (void)
{
                MFP_P31_UART0_TXD;
                P31_QUASI_MODE;
                UART_Open(24000000,UART0_Timer1,115200);
                ENABLE_UART0_PRINTF;       
       
/* Define P25 multi-function pin as External pin interrupt INT0 source*/
                MFP_P25_INT0;                                                                                                                               
                P25_INPUT_MODE;
/* Enable internal pull up function to wait falling edge*/
                GPIO_Pull_Enable(Port2,SET_BIT5,PullUp);
/* Include exint.c in library */
                ExternPinInterrupt_Enable(INT0,Edge,Enable);
                ENABLE_GLOBAL_INTERRUPT;                                                                       
                while(1);
       
}








使用特权

评论回复
沙发
捉虫天师|  楼主 | 2019-8-31 23:49 | 只看该作者
/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* Copyright(c) 2019 Nuvoton Technology Corp. All rights reserved.                                         */
/*                                                                                                         */
/*---------------------------------------------------------------------------------------------------------*/

//***********************************************************************************************************
//  Website: http://www.nuvoton.com
//  E-Mail : MicroC-8bit@nuvoton.com
//***********************************************************************************************************

#include "ML51.h"

/**
* @brief              External pin interrupt INT1 demo
* @param       None
* @return      None
* @details     None
*/


void INT1_ISR(void) interrupt 2          // Vector @  0x13
{
/* Clear INT1 interrupt flag */
    clr_TCON_IE1;
/* check tiny board LEDG1 to confirm into interrupt */
                P31 = ~P31;
}

void main (void)
{
                MFP_P31_GPIO;
                P31_PUSHPULL_MODE;
/* Define P24 multi-function pin as External pin interrupt INT1 source*/
                MFP_P24_INT1;                                                                                                                               
                P24_INPUT_MODE;       
/* Enable P2.4 internal pull high to wait falling edge*/       
                GPIO_Pull_Enable(Port2,SET_BIT4,PullUp);       
/* Include exint.c in library */
                ExternPinInterrupt_Enable(INT1,Edge,Enable);
/* Include sys.c */
                ENABLE_GLOBAL_INTERRUPT;                                                                       
                while(1);
}






使用特权

评论回复
板凳
捉虫天师|  楼主 | 2019-8-31 23:50 | 只看该作者
这两个特别的外部中断也是为了保持跟传统51兼容而留下的。

使用特权

评论回复
地板
捉虫天师|  楼主 | 2019-9-10 23:59 | 只看该作者
这个功能很强。

使用特权

评论回复
5
yiyigirl2014| | 2019-9-11 00:25 | 只看该作者
和GPIO中断比,这种是不是更快

使用特权

评论回复
6
wanduzi| | 2019-9-16 23:43 | 只看该作者
跟51的使用方法一样。

使用特权

评论回复
7
玛尼玛尼哄| | 2019-9-16 23:48 | 只看该作者
这个还可以GPIO中断。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

192

主题

3047

帖子

7

粉丝