void Init_ADC(void) { GPIO_Init(GPIOD, (GPIO_Pin_TypeDef)(GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_6), GPIO_MODE_IN_FL_NO_IT); ADC1_DeInit(); ADC1_Cmd(ENABLE); ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, ADC1_CHANNEL_3, ADC1_PRESSEL_FCPU_D18, ADC1_EXTTRIG_TIM, DISABLE...
void Init_ADC(void) { GPIO_Init(GPIOD, (GPIO_Pin_TypeDef)(GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_6), GPIO_MODE_IN_FL_NO_IT); ADC1_DeInit(); ADC1_Cmd(ENABLE); ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, ADC1_CHANNEL_3, ADC1_PRESSEL_FCPU_D18, ADC1_EXTTRIG_TIM, DISABLE...
ADC1_Cmd(ENABLE);//放在前面 ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, ADC1_CHANNEL_3, ADC1_PRESSEL_FCPU_D8, ADC1_EXTTRIG_TIM, DISABLE, ADC1_ALIGN_RIGHT, ADC1_SCHMITTTRIG_CHANNEL3,DISABLE); ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS, ADC1_CHANNEL_4, ADC1_PRESSEL_FCPU_D8, ADC1_EXT...
void adc1_init(void); /* 初始化ADC1 */ float get_voltage(void); /* 获取ADC电压值 */ uint16_t get_adc_val(void); /* 获取ADC值 */ #endif /* __ADC1_H__ */ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24....
ADC1_DeInit();ADC1_Init(ADC1_CONVERSIONMODE_CONTINUOUS,ADC_Channel_Number,ADC1_PRESSEL_FCPU_D...
ADC1_Cmd(ENABLE);} void main(void){ FlagStatus flag_status;u16 u16_adc1_value;Init_UART2()...
ADC1的配置与采样函数都在adc.c文件实现: ADC1配置函数: void ADC1_Config(void**)** { //打开ADC1外设的时钟 CLK_PeripheralClockConfig(CLK_Peripheral_ADC1**,** ENABLE**);** //配置ADC1的GPIO为浮空输入模式 GPIO_Init(ADC_IN22_GPIO_PORT**,** ADC_IN22_GPIO_PINS**,** GPIO_Mode_In_FL...
/* Initialize and configure ADC1 */ ADC_Init(ADC1, ADC_ConversionMode_Continuous, ADC_Resolution_12Bit, ADC_Prescaler_2); ADC_SamplingTimeConfig(ADC1, ADC_Group_SlowChannels, ADC_SamplingTime_384Cycles); /* Enable ADC1 */ ADC_Cmd(ADC1, ENABLE); ...
GPIO_Init(GPIOB, GPIO_PIN_0, GPIO_MODE_IN_FL_NO_IT);ADC1_DeInit();ADC1_Init(ADC1_...
#define _adc_H #include "stm8l15x.h" void Adc_Init(void); #endif adc.c源文件: #include "adc.h" void Adc_Init(void) { CLK_PeripheralClockConfig(CLK_Peripheral_ADC1,ENABLE);//开启ADC1时钟 ADC_VrefintCmd(ENABLE); //使能内部参考电压 ...