[DemoCode下载] N79E715的GPIO操作

[复制链接]
1182|12
 楼主| zhuotuzi 发表于 2016-12-29 23:48 | 显示全部楼层 |阅读模式
  1. /*---------------------------------------------------------------------------------------------------------*/
  2. /*                                                                                                         */
  3. /* Copyright(c) 2015 Nuvoton Technology Corp. All rights reserved.                                         */
  4. /*                                                                                                         */
  5. /*---------------------------------------------------------------------------------------------------------*/

  6. //***********************************************************************************************************
  7. //  Nuvoton Technology Corp.
  8. //  E-mail: MicroC-8bit@nuvoton.com
  9. //***********************************************************************************************************
  10. //  Application: GPIO Sample Code
  11. //
  12. //  Output : P1.4 & P2.1 toggle
  13. //***********************************************************************************************************

  14. //------------------------- <<< Use Configuration Wizard in Context Menu >>> --------------------------------
  15. //     <o0.6> UART pin Select
  16. //          <0=> Select P1.0, P1.1 as UART pin(default)
  17. //          <1=> Select P2.6, P2.7 as UART pin(28 pin only)
  18. //-------------------------------- <<< end of configuration section >>> -------------------------------------

  19. #define Uart_Port_Sel   0x00

  20. #include <stdio.h>
  21. #include "N79E715.h"
  22. #include "Typedef.h"
  23. #include "Define.h"
  24. #include "Common.h"
  25. #include "Delay.h"
  26. #include "Version.h"
  27. //-----------------------------------------------------------------------------------------------------------
  28. void main(void)
  29. {
  30.     AUXR1 |= Uart_Port_Sel;         // Select P10/P11 as UART pin(default)
  31.     InitialUART0_Timer1(9600);      // 9600 Baud Rate [url=home.php?mod=space&uid=72445]@[/url] 11.0592MHz
  32.     Show_Version_Number_To_PC();
  33.     printf ("\n*===================================================================");
  34.     printf ("\n*  Name: N79E715 Series GPIO Sample Code.");
  35.     printf ("\n*===================================================================");

  36.     while(1)
  37.     {
  38.         P14 = 0;
  39.         P21 = 0;
  40.         Delay1ms(100);

  41.         P14 = 1;
  42.         P21 = 1;
  43.         Delay1ms(100);
  44.     }
  45. }
  46. //-----------------------------------------------------------------------------------------------------------


 楼主| zhuotuzi 发表于 2016-12-29 23:50 | 显示全部楼层
是不是很简单,新唐的51开发,比老51方便多了。
 楼主| zhuotuzi 发表于 2016-12-29 23:51 | 显示全部楼层
AUXR1 |= Uart_Port_Sel;         // Select P10/P11 as UART pin(default)
    InitialUART0_Timer1(9600);      // 9600 Baud Rate @ 11.0592MHz
    Show_Version_Number_To_PC();
    printf ("\n*===================================================================");
串口使用也是超级超级简单,
选择使用串口后,就直接初始化就行了。
dongnanxibei 发表于 2016-12-30 00:00 | 显示全部楼层
直接可以输出输入的, 51的方便就是这里,不用配置IO的类型,直接用。
734774645 发表于 2016-12-30 10:38 | 显示全部楼层
系统自带的还有delay函数,不错啊
 楼主| zhuotuzi 发表于 2016-12-30 17:12 | 显示全部楼层
还有一个特殊的头文件,获取版本信息。
墙上的咖啡 发表于 2016-12-30 19:56 | 显示全部楼层
这不是标志51的操作吗?也是51的内核吗?
yiyigirl2014 发表于 2016-12-30 23:11 | 显示全部楼层
//     <o0.6> UART pin Select
//          <0=> Select P1.0, P1.1 as UART pin(default)
//          <1=> Select P2.6, P2.7 as UART pin(28 pin only)
 楼主| zhuotuzi 发表于 2017-1-4 17:03 | 显示全部楼层
yiyigirl2014 发表于 2016-12-30 23:11
//      UART pin Select
//           Select P1.0, P1.1 as UART pin(default)
//           Select P2.6 ...

配置不同的IO管脚的第二功能。
yiyigirl2014 发表于 2017-1-6 10:04 | 显示全部楼层
有不少人会觉得我配置好了,怎么没这个功能,实际上可能你后面代码动了那个之前的配置。
 楼主| zhuotuzi 发表于 2017-1-7 08:43 | 显示全部楼层
如果自己不会写delay函数的,也可以参考这个,不一定都是循环跑空指令。可以用定时器比较准的。
 楼主| zhuotuzi 发表于 2017-1-21 17:46 | 显示全部楼层
纯粹的51单片机操作,确实比现在好多ARM的方便,不过为了这个方便使用了复杂指令集。
捉虫天师 发表于 2017-1-22 19:06 | 显示全部楼层
是有个版本信息。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

214

主题

3375

帖子

7

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