[DemoCode下载] N76E616 低功耗电流演示

[复制链接]
1166|9
 楼主| 734774645 发表于 2019-5-19 11:29 | 显示全部楼层 |阅读模式
  1. /*---------------------------------------------------------------------------------------------------------*/
  2. /*                                                                                                         */
  3. /* Copyright(c) 2015 Nuvoton Technology Corp. All rights reserved.                                         */
  4. /*                                                                                                         */
  5. /*---------------------------------------------------------------------------------------------------------*/

  6. //***********************************************************************************************************
  7. //  Nuvoton Technoledge Corp.
  8. //  Website: http://www.nuvoton.com
  9. //  E-Mail : MicroC-8bit@nuvoton.com
  10. //  Date   : Sep/1/2015
  11. //***********************************************************************************************************

  12. //***********************************************************************************************************
  13. //  File Function: N76E616 Current demo code
  14. //***********************************************************************************************************

  15. #include <stdio.h>
  16. #include "N76E616.h"
  17. #include "Version.h"
  18. #include "Typedef.h"
  19. #include "Define.h"
  20. #include "SFR_Macro.h"
  21. #include "Common.h"
  22. #include "Delay.h"

  23. /*
  24. //-------- <<< Use Configuration Wizard in Context Menu >>> ------------------
  25. //
  26. //<e0> System Clock Source Configuration
  27. // <o1> System Clock Source Selection
  28. //      <0=> 2~16MHz    XTAL
  29. //      <1=> 32.768KHz  XTAL
  30. //      <2=> 11.0592MHz Internal
  31. //      <3=> 10KHz      Internal
  32. //      <4=> OSC-In     External
  33. //</e>
  34. //
  35. //<e2> Clock Divider Configuration
  36. //     <o3.0..7>  System Clock Source Devider <1-255:1>
  37. //                     <i> Fsys = (System Clock Source) / (2 * Devider)
  38. //</e>
  39. //
  40. //<e4> Brown-out Detection Control 0
  41. // <o5> Brown-out Detection voltage Selection
  42. //      <0=> BOD4.3V
  43. //      <1=> BOD3.8V
  44. //      <2=> BOD2.7V
  45. //      <3=> BOD2.2V
  46. //</e>
  47. //
  48. //<e6> Brown-out Detection Filter Control
  49. //</e>
  50. //
  51. // <o7> Brown-out Detection Low Power Mode Selection
  52. //      <0=> BOD Normal mode
  53. //      <1=> BOD low power mode 1
  54. //      <2=> BOD low power mode 2
  55. //      <3=> BOD low power mode 3
  56. //
  57. // <o8> System Operate Mode Selection
  58. //      <0=> Normal mode
  59. //      <1=> Idle mode
  60. //      <2=> Power down mode
  61. //-------- <<< end of configuration section >>> ------------------------------
  62. */

  63. #define SYS_CLK_EN      1
  64. #define SYS_SEL         3
  65. #define SYS_DIV_EN      0                   //0: Fsys=Fosc, 1: Fsys = Fosc/(2*CKDIV)
  66. #define SYS_DIV         1
  67. #define BOD_EN          0
  68. #define BOD_VOLT_SEL    0
  69. #define BOD_FILTER_EN   0
  70. #define BOD_MODE_SEL    0
  71. #define SYS_OP_MODE_SEL 2

  72. bit BIT_TMP;



  73. /******************************************************************************
  74. The main C function.  Program execution starts
  75. here after stack initialization.
  76. ******************************************************************************/
  77. void main (void)
  78. {
  79.     /* Note
  80.        MCU power on system clock is HIRC (11.0592MHz), so Fsys = 11.0592MHz
  81.     */
  82.    
  83.     Set_All_GPIO_Quasi_Mode();

  84.     #if DEBUG_PORT == 0
  85.         InitialUART0_Timer1_Type1(9600);            /* 9600 Baud Rate*/
  86.     #elif DEBUG_PORT == 1
  87.         InitialUART1_Timer3(9600);                  /* 9600 Baud Rate*/
  88.     #endif  
  89.     Show_FW_Version_Number_To_PC();

  90.     printf ("\n*===================================================================");
  91.     printf ("\n*  Name: N76E616 Current Demo Code.");
  92.     printf ("\n*===================================================================\n");
  93.         
  94.     /* Change system closk source */
  95.     #if SYS_CLK_EN == 1
  96.         #if   SYS_SEL == 1
  97.             System_Clock_Select(E_HXTEN);   //Fosc = 2~16MHz XTAL
  98.         #elif SYS_SEL == 1
  99.             System_Clock_Select(E_LXTEN);   //Fosc = 32.768KHz XTAL        
  100.         #elif SYS_SEL == 2
  101.             System_Clock_Select(E_HIRCEN);  //Fosc = 11.0592MHz Internal RC
  102.         #elif SYS_SEL == 3
  103.             System_Clock_Select(E_LIRCEN);  //Fosc = 10KHz Internal RC
  104.         #elif SYS_SEL == 4
  105.             System_Clock_Select(E_OSCEN);   //Fosc = OSC-In External OSC
  106.         #endif
  107.     #endif
  108.    
  109.     /* Turn off other none system closk sources */
  110.     #if   SYS_SEL == 1                      //Fosc = 2~16MHz XTAL
  111.         clr_HIRCEN;
  112.         clr_LIRCEN;
  113.     #elif SYS_SEL == 2                      //Fosc = 11.0592MHz Internal RC
  114.         clr_EXTEN1;
  115.         clr_EXTEN0;
  116.         clr_LIRCEN;
  117.     #elif SYS_SEL == 3                      //Fosc = 10KHz Internal RC
  118.         clr_EXTEN1;
  119.         clr_EXTEN0;
  120.         clr_HIRCEN;
  121.     #elif SYS_SEL == 4                      //Fosc = OSC-In External OSC
  122.         clr_HIRCEN;
  123.         clr_LIRCEN;
  124.     #endif
  125.            
  126.     #if SYS_DIV_EN == 1
  127.         CKDIV = SYS_DIV;                    //Fsys = Fosc / (2* CLKDIV) = Fcpu
  128.     #endif
  129.    
  130.     /* Turn on/off BOD function */
  131.     #if   BOD_EN == 0
  132.         clr_BODEN;
  133.     #elif BOD_EN == 1
  134.         set_BODEN;
  135.     #endif
  136.    
  137.     /* BOD voltage selection */
  138.     #if   BOD_VOLT_SEL == 0
  139.         clr_BOV1;
  140.         clr_BOV0;
  141.     #elif BOD_VOLT_SEL == 1
  142.         clr_BOV1;
  143.         set_BOV0;
  144.     #elif BOD_VOLT_SEL == 2
  145.         set_BOV1;
  146.         clr_BOV0;
  147.     #elif BOD_VOLT_SEL == 3
  148.         set_BOV1;
  149.         set_BOV0;
  150.     #endif
  151.    
  152.     /* BOD filter control */
  153.     #if   BOD_FILTER_EN == 0
  154.         clr_BODFLT;
  155.     #elif   BOD_FILTER_EN == 1
  156.         set_BODFLT;
  157.     #endif   
  158.    
  159.     /* BOD low power mode selection */
  160.     #if   BOD_MODE_SEL == 0
  161.         clr_LPBOD1;
  162.         clr_LPBOD0;
  163.     #elif BOD_MODE_SEL == 1
  164.         clr_LPBOD1;
  165.         set_LPBOD0;
  166.     #elif BOD_MODE_SEL == 2
  167.         set_LPBOD1;
  168.         clr_LPBOD0;
  169.     #elif BOD_MODE_SEL == 3
  170.         set_LPBOD1;
  171.         set_LPBOD0;
  172.     #endif
  173.    
  174.     /* System operate mode selection */
  175.     #if   SYS_OP_MODE_SEL == 0
  176.         while(1);
  177.     #elif SYS_OP_MODE_SEL == 1
  178.         set_IDLE;
  179.         while(1);
  180.     #elif SYS_OP_MODE_SEL == 2
  181.         set_PD;
  182.         while(1);
  183.     #endif

  184. while(1);

  185. }




 楼主| 734774645 发表于 2019-5-19 11:29 | 显示全部楼层
Current
Demonstrate power down, idle or operating mode power consumption.
 楼主| 734774645 发表于 2019-5-19 11:29 | 显示全部楼层
其实除了N76E003新唐其他的51内核单片机也是很牛的。
捉虫天师 发表于 2019-5-19 12:17 | 显示全部楼层
51低功耗系列更给力。
xuanhuanzi 发表于 2019-5-19 16:20 | 显示全部楼层
BOD给力啊,是不是还可以实现掉电保存数据
huahuagg 发表于 2019-5-19 17:21 | 显示全部楼层
采用不同时钟是不是也功耗不同啊?
xinxianshi 发表于 2019-5-19 19:40 | 显示全部楼层
好像新唐的都具备BOD
xinxianshi 发表于 2019-5-19 19:41 | 显示全部楼层
我之前用MSP432的都没这个高级功能,看来新唐要比美国人技高一筹。
QQ1099811789 发表于 2019-5-20 17:03 | 显示全部楼层
xinpian101 发表于 2019-5-21 23:26 | 显示全部楼层
新唐貌似很多系列都考虑了低功耗。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

211

主题

3588

帖子

15

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