[DemoCode下载] ML51的GPIO基本操作

[复制链接]
3066|10
 楼主| 天灵灵地灵灵 发表于 2019-1-4 11:58 | 显示全部楼层 |阅读模式
  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. //***********************************************************************************************************
  11. //  File Function: ML51 simple GPIO toggle out demo code
  12. //***********************************************************************************************************

  13. #include "ML51.h"

  14. /**
  15. * [url=home.php?mod=space&uid=247401]@brief[/url]       GPIO input output demo
  16. * @param       None
  17. * [url=home.php?mod=space&uid=266161]@return[/url]      None
  18. * [url=home.php?mod=space&uid=1543424]@Details[/url]     GPIO toggle and UART0 TXD0 send out.
  19. */
  20. void main (void)
  21. {

  22.       MFP_P46_GPIO;
  23.       P31_PUSHPULL_MODE;
  24.       MFP_P50_GPIO;
  25.       P50_PUSHPULL_MODE;
  26.       MFP_P51_GPIO;
  27.       P51_PUSHPULL_MODE;

  28. /*
  29. For UART0 P3.1 as TXD output setting
  30. * include uart.c in Common Setting for UART0
  31. */
  32.     MFP_P31_UART0_TXD;                              // UART0 TXD use P1.6
  33.     P31_QUASI_MODE;                                  // set P1.6 as Quasi mode for UART0 trasnfer
  34.     UART_Open(24000000,UART0_Timer1,115200);        // Open UART0 use timer1 as baudrate generate and baud rate = 115200

  35.     while(1)
  36.     {
  37.       SFRS = 0;
  38.       P46 ^= 1;
  39.       while (P5|CLR_BIT6); // P56 = 1;
  40.       while (!(P5&SET_BIT6)); // P56 = 0;

  41. /* include timer.c for delay setting */
  42.       Timer2_Delay(24000000,128,100,1000);
  43.       UART_Send_Data(UART0,0x55);  
  44.     }
  45.   
  46. }


 楼主| 天灵灵地灵灵 发表于 2019-1-4 11:59 | 显示全部楼层
GPIO 掉电演示

  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. //***********************************************************************************************************
  11. //  File Function: ML51 simple GPIO toggle out demo code
  12. //***********************************************************************************************************

  13. #include "ML51.h"

  14. void PinInterrupt_ISR (void) interrupt 7
  15. {
  16.     PIF = 0;
  17. }

  18. /**
  19. * @brief       Port0~5 Interrupt Subroutine
  20. * @param       None
  21. * @return      None
  22. * @details     GPIO P13 toggle out and UART0 TXD0 send out.
  23. */

  24. void main (void)
  25. {
  26.    unsigned char ct;
  27. /* Setting Multi function pin setting for GPIO toggle
  28.    * include gipo.c in Common for GPIO mode setting
  29. */
  30.     ALL_GPIO_QUASI_MODE;
  31.     P0 = 0xFF;
  32.     P1 = 0xFF;
  33.     P2 = 0xFF;
  34.     P3 = 0xFF;
  35.     P4 = 0xFF;
  36.     P5 = 0xFF;
  37.     MFP_P17_GPIO;
  38.     DISABLE_BOD;
  39.   
  40.     SFRS=0;
  41.     for(ct=0;ct<0x05;ct++)
  42.     {
  43.         P31 = 0;
  44.         _delay_();
  45.         P31 = 1;
  46.         _delay_();
  47.     }
  48.      P31 = 0;
  49.     set_PCON_PD;
  50.     while(1);

  51. }


捉虫天师 发表于 2019-1-7 14:09 | 显示全部楼层
每个定时器的都给出了延时函数了吗
幸福小强 发表于 2019-1-7 18:40 | 显示全部楼层
发现高级的用法就是判断时候使用逻辑操作。
zhuotuzi 发表于 2019-1-7 23:04 | 显示全部楼层
新唐大部分的ARM系列,IO操作是一致兼容的。
chineseboyzxy 发表于 2019-1-24 11:10 | 显示全部楼层
ML51TC0AE的GPIO,在强推挽和开漏模式下的灌电流允许多大?
捉虫天师 发表于 2019-1-28 22:51 | 显示全部楼层
数据手册应该有端口的电流电压参数。
wanduzi 发表于 2019-1-29 20:29 | 显示全部楼层
多多练习。
Harvard 发表于 2019-1-29 23:16 | 显示全部楼层
什么地方可以买到ml51的板子啊
 楼主| 天灵灵地灵灵 发表于 2019-2-23 18:50 | 显示全部楼层
ML系列会火。
 楼主| 天灵灵地灵灵 发表于 2019-2-23 18:50 | 显示全部楼层
大家可以试试,使用51就实现低功耗,只有新唐。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

183

主题

3475

帖子

13

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