打印
[DemoCode下载]

ML51的外部中断

[复制链接]
362|5
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
598330983|  楼主 | 2019-9-29 23:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* 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 INT1 demo
* @param       None
* [url=home.php?mod=space&uid=266161]@return[/url]      None
* [url=home.php?mod=space&uid=1543424]@Details[/url]     None
*/


void INT1_ISR(void) interrupt 2          // Vector [url=home.php?mod=space&uid=72445]@[/url]  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);
}








使用特权

评论回复
沙发
598330983|  楼主 | 2019-9-29 23:40 | 只看该作者
/*---------------------------------------------------------------------------------------------------------*/
/*                                                                                                         */
/* 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 INT0 demo
* @param       None
* @return      None
* @details     None
*/


void INT0_ISR(void) interrupt 0          // Vector @  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);
       
}






使用特权

评论回复
板凳
598330983|  楼主 | 2019-9-29 23:40 | 只看该作者
这个例子还展示了如何用printf函数。

使用特权

评论回复
地板
yiy| | 2019-9-30 16:10 | 只看该作者
非常给力,这价格比传统51便宜多了,主要提供库函数,51内核里单片机好像只有新唐做到了

使用特权

评论回复
5
heisexingqisi| | 2019-9-30 20:20 | 只看该作者
其实这个作为农场监控也不错啊,低功耗。

使用特权

评论回复
6
wanduzi| | 2019-10-9 21:24 | 只看该作者
interrupt 2
这个从哪儿看

使用特权

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

本版积分规则

227

主题

5279

帖子

22

粉丝