ADC.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* --------------------------- (C) COPYRIGHT 2021 Fortiortech ShenZhen -----------------------------
  2. File Name : ADC.c
  3. Author : Fortiortech Appliction Team
  4. Version : V1.0
  5. Date : 2021-04-11
  6. Description : This file contains .C file function used for Motor Control.
  7. ----------------------------------------------------------------------------------------------------
  8. All Rights Reserved
  9. ------------------------------------------------------------------------------------------------- */
  10. #include <Myproject.h>
  11. void ADC_Init(void)
  12. {
  13. /********************ADC 端口模拟功能设置************************/
  14. SetBit(P2_AN , PIN0); //AD0 P20 CH open--IU--固定
  15. SetBit(P2_AN , PIN3); //AD1 P23 CH open--IV--固定
  16. SetBit(P2_AN , PIN4); //AD2 P24 CH open--IV--固定
  17. SetBit(P2_AN , PIN5); //AD3 P25 CH open
  18. SetBit(P2_AN , PIN7); //AD4 P27 CH open--IBUS/IW--固定
  19. // SetBit(P3_AN , PIN2); //AD5 P32 CH open
  20. // SetBit(P3_AN , PIN3); //AD6 P33 CH open
  21. SetBit(P3_AN , PIN4); //AD7 P34 CH open
  22. // SetBit(P2_AN , PIN1); //AD8 P21 CH open
  23. // SetBit(P1_AN , PIN6); //AD9 P16 CH open
  24. // SetBit(P1_AN , PIN4); //AD10 P14 CH open
  25. // SetBit(P2_AN , PIN6); //AD11 P26 CH open
  26. // SetBit(P1_AN , PIN3); //AD12 P13 CH open
  27. // SetBit(P1_AN , PIN5); //AD13 P15 CH open
  28. /****************************************************************/
  29. SetBit(ADC_MASK , CH0EN | CH1EN | CH2EN| CH3EN | CH4EN | CH7EN| CH11EN); //通道使能
  30. SetBit(ADC_CR , ADCALIGN); //ADC数据次高位对齐使能0-->Disable 1-->Enable
  31. ADC_SCYC = 0x36;
  32. ClrBit(ADC_CR , ADCIE); //ADC中断使能
  33. SetBit(ADC_CR , ADCEN); //Enable ADC0
  34. }