ADC.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * @copyright None
  3. * @file ADC.c
  4. * @author Comment Vivre
  5. * @date 2024-08-28
  6. * @brief None
  7. */
  8. #include <Myproject.h>
  9. /**
  10. * @function ADC_Init
  11. * @brief ADC端口初始化
  12. * @param[in] None
  13. * @return None
  14. * @date 2024-08-28
  15. */
  16. void ADC_Init(void)
  17. {
  18. // SetBit(P2_AN, PIN0); //AD0 P20 CH open--IU--固定
  19. // SetBit(P2_AN, PIN3); //AD1 P23 CH open--IV--固定
  20. SetBit(P2_AN, PIN4); //AD2 P24 OVP √
  21. // SetBit(P2_AN, PIN5); //AD3 P25 CH open
  22. SetBit(P2_AN, PIN7); //AD4 P27 CH open--IBUS/IW--固定
  23. // SetBit(P3_AN , PIN2); //AD5 P32 CH open
  24. // SetBit(P3_AN , PIN3); //AD6 P33 CH open
  25. // SetBit(P3_AN, PIN4); //AD7 P34 CH open
  26. SetBit(P2_AN, PIN1); //AD8 P21 MOS √
  27. SetBit(P1_AN, PIN6); //AD9 P16 VSP
  28. // SetBit(P1_AN , PIN4); //AD10 P14 CH open
  29. // SetBit(P2_AN , PIN6); //AD11 P26 CH open
  30. // SetBit(P1_AN , PIN3); //AD12 P13 CH open
  31. // SetBit(P1_AN , PIN5); //AD13 P15 CH open
  32. SetBit(ADC_MASK,CH2EN | CH4EN | CH8EN | CH9EN); //通道使能
  33. SetBit(ADC_CR, ADCALIGN); //ADC数据次高位对齐使能0-->Disable 1-->Enable
  34. ADC_SCYC = 0x36;
  35. ClrBit(ADC_CR, ADCIE); //ADC中断使能
  36. SetBit(ADC_CR, ADCEN); //Enable ADC0
  37. }