[DemoCode下载] ADC多通道操作

[复制链接]
1474|4
 楼主| antusheng 发表于 2019-6-30 23:13 | 显示全部楼层 |阅读模式
  1. /*---------------------------------------------------------------------------------------------------------*/
  2. /*                                                                                                         */
  3. /* Copyright(c) 2017 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/2017
  10. //***********************************************************************************************************

  11. //***********************************************************************************************************
  12. //  File Function: N76E003  ADC mutli channel demo code
  13. //***********************************************************************************************************
  14. #include "N76E003.h"
  15. #include "SFR_Macro.h"
  16. #include "Function_define.h"
  17. #include "Common.h"
  18. #include "Delay.h"

  19. //*****************  The Following is in define in Fucntion_define.h  ***************************
  20. //****** Always include Function_define.h call the define you want, detail see main(void) *******
  21. //***********************************************************************************************
  22.                 unsigned char ADCdataH[4], ADCdataL[4];

  23.                                
  24. /******************************************************************************
  25. The main C function.  Program execution starts
  26. here after stack initialization.
  27. ******************************************************************************/
  28. void main (void)
  29. {
  30.                 unsigned char i;       

  31.        
  32.         while(1)
  33.         {
  34.                 CKDIV = 0x02;                                                                                                                        // IMPORTANT!! Modify system clock to 4MHz ,then add the ADC sampling clock base to add the sampling timing.
  35.                 i = 0;
  36.                         Enable_ADC_AIN0;
  37.                         clr_ADCF;
  38.                         set_ADCS;                                                                                                                               
  39.       while(ADCF == 0);
  40.                         ADCdataH[i] = ADCRH;
  41.                         ADCdataL[i] = ADCRL;
  42.                         Disable_ADC;
  43.                 i++;
  44.                
  45.                         Enable_ADC_BandGap;
  46.                         clr_ADCF;
  47.                         set_ADCS;                                                                                                                               
  48.       while(ADCF == 0);
  49.                         ADCdataH[i] = ADCRH;
  50.                         ADCdataL[i] = ADCRL;
  51.                         Disable_ADC;
  52.                 i++;
  53.                
  54.                         Enable_ADC_AIN3;
  55.                         clr_ADCF;
  56.                         set_ADCS;                                                                                                                               
  57.       while(ADCF == 0);
  58.                         ADCdataH[i] = ADCRH;
  59.                         ADCdataL[i] = ADCRL;
  60.                         Disable_ADC;
  61.                 CKDIV = 0x00;       
  62.         }
  63.                
  64.        
  65. }


 楼主| antusheng 发表于 2019-6-30 23:14 | 显示全部楼层
可以多通道操作,非常方便。
zhuomuniao110 发表于 2019-6-30 23:16 | 显示全部楼层
这就是操作完一个设置另外一个通道来实现。
feng2046 发表于 2024-10-15 14:57 | 显示全部楼层
PDMA模式怎么设置
您需要登录后才可以回帖 登录 | 注册

本版积分规则

86

主题

1521

帖子

5

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