[DemoCode下载] ML51基于寄存器配置外部中断方法

[复制链接]
893|5
 楼主| 捉虫天师 发表于 2019-11-29 21:32 | 显示全部楼层 |阅读模式
  1. /*---------------------------------------------------------------------------------------------------------*/
  2. /*                                                                                                         */
  3. /* Copyright(c) 2019 Nuvoton Technology Corp. All rights reserved.                                         */
  4. /*                                                                                                         */
  5. /*---------------------------------------------------------------------------------------------------------*/

  6. //***********************************************************************************************************
  7. //  Website: http://www.nuvoton.com
  8. //  E-Mail : MicroC-8bit@nuvoton.com
  9. //  Date   : Jan/21/2019
  10. //***********************************************************************************************************

  11. //***********************************************************************************************************
  12. //  File Function: ML51 INT0 pin demo
  13. //***********************************************************************************************************
  14. #include "ML51.H"

  15. /* External pin interrupt INT0 subroutine */
  16. void INT0_ISR(void) interrupt 0          // Vector [url=home.php?mod=space&uid=72445]@[/url]  0x03
  17. {
  18.     clr_TCON_IE0;          //clr int flag wait next falling edge
  19.     printf ("\n INT0 interrupt !!");
  20. }


  21. void main (void)
  22. {
  23. /* Initial UART0 for printf */
  24.     MFP_P31_UART0_TXD;
  25.     P31_PUSHPULL_MODE;
  26.     UART_Open(24000000,UART0_Timer3,115200);
  27.     ENABLE_UART0_PRINTF;
  28.   
  29. /*INT0 ENABLE */
  30.     MFP_P25_INT0;                       //setting INT0 pin P0.6 as Quasi mode
  31.     P25_INPUT_MODE;                    //Set input mode
  32.     ENABLE_P25_PULLUP;                 //set pull up resistor.
  33.     INT0_FALLING_EDGE_TRIG;              //setting trig condition level or edge
  34.     ENABLE_INT0_INTERRUPT;                         //INT0_Enable;
  35.     ENABLE_GLOBAL_INTERRUPT;            //Global interrupt enable
  36.     while(1);
  37. }





jiekou001 发表于 2019-11-29 21:35 | 显示全部楼层
看起来比库函数简短。
天灵灵地灵灵 发表于 2019-11-30 17:54 | 显示全部楼层
定义好的宏,跟库函数差不多的方便。
yulin0668 发表于 2019-12-25 10:02 | 显示全部楼层
这个不错,值得学习下
天灵灵地灵灵 发表于 2019-12-25 13:34 | 显示全部楼层
看起来比003还好用。
21mengnan 发表于 2019-12-26 12:00 | 显示全部楼层
外部中断比PIN中断好用多了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

213

主题

3276

帖子

7

粉丝
快速回复 在线客服 返回列表 返回顶部