[DemoCode下载] ML51的外部中断

[复制链接]
823|5
 楼主| 598330983 发表于 2019-9-29 23:40 | 显示全部楼层 |阅读模式
  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. //***********************************************************************************************************

  10. #include "ML51.h"

  11. /**
  12. * [url=home.php?mod=space&uid=247401]@brief[/url]              External pin interrupt INT1 demo
  13. * @param       None
  14. * [url=home.php?mod=space&uid=266161]@return[/url]      None
  15. * [url=home.php?mod=space&uid=1543424]@Details[/url]     None
  16. */


  17. void INT1_ISR(void) interrupt 2          // Vector [url=home.php?mod=space&uid=72445]@[/url]  0x13
  18. {
  19. /* Clear INT1 interrupt flag */
  20.     clr_TCON_IE1;
  21. /* check tiny board LEDG1 to confirm into interrupt */
  22.                 P31 = ~P31;
  23. }

  24. void main (void)
  25. {
  26.                 MFP_P31_GPIO;
  27.                 P31_PUSHPULL_MODE;
  28. /* Define P24 multi-function pin as External pin interrupt INT1 source*/
  29.                 MFP_P24_INT1;                                                                                                                               
  30.                 P24_INPUT_MODE;       
  31. /* Enable P2.4 internal pull high to wait falling edge*/       
  32.                 GPIO_Pull_Enable(Port2,SET_BIT4,PullUp);       
  33. /* Include exint.c in library */
  34.                 ExternPinInterrupt_Enable(INT1,Edge,Enable);
  35. /* Include sys.c */
  36.                 ENABLE_GLOBAL_INTERRUPT;                                                                       
  37.                 while(1);
  38. }








 楼主| 598330983 发表于 2019-9-29 23:40 | 显示全部楼层
  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. //***********************************************************************************************************

  10. #include "ML51.h"

  11. /**
  12. * @brief              External pin interrupt INT0 demo
  13. * @param       None
  14. * @return      None
  15. * @details     None
  16. */


  17. void INT0_ISR(void) interrupt 0          // Vector @  0x03
  18. {
  19. /* Clear INT0 interrupt flag */
  20.                 clr_TCON_IE0;
  21.                 printf ("\n INT0 interrupt");
  22. }


  23. void main (void)
  24. {
  25.                 MFP_P31_UART0_TXD;
  26.                 P31_QUASI_MODE;
  27.                 UART_Open(24000000,UART0_Timer1,115200);
  28.                 ENABLE_UART0_PRINTF;       
  29.        
  30. /* Define P25 multi-function pin as External pin interrupt INT0 source*/
  31.                 MFP_P25_INT0;                                                                                                                               
  32.                 P25_INPUT_MODE;
  33. /* Enable internal pull up function to wait falling edge*/
  34.                 GPIO_Pull_Enable(Port2,SET_BIT5,PullUp);
  35. /* Include exint.c in library */
  36.                 ExternPinInterrupt_Enable(INT0,Edge,Enable);
  37.                 ENABLE_GLOBAL_INTERRUPT;                                                                       
  38.                 while(1);
  39.        
  40. }






 楼主| 598330983 发表于 2019-9-29 23:40 | 显示全部楼层
这个例子还展示了如何用printf函数。
yiy 发表于 2019-9-30 16:10 来自手机 | 显示全部楼层
非常给力,这价格比传统51便宜多了,主要提供库函数,51内核里单片机好像只有新唐做到了
heisexingqisi 发表于 2019-9-30 20:20 | 显示全部楼层
其实这个作为农场监控也不错啊,低功耗。
wanduzi 发表于 2019-10-9 21:24 | 显示全部楼层
interrupt 2
这个从哪儿看
您需要登录后才可以回帖 登录 | 注册

本版积分规则

267

主题

5575

帖子

22

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