初次弄这玩意,不知道错误在哪,麻烦哪位大神帮忙指点下。
下面的是STM8L的初始化代码
//init clock
CLK_PeripheralClockConfig(CLK_Peripheral_ADC1, ENABLE);
// Set PB7 as Input floating no INT - ADC_1
GPIO_Init(GPIOB, GPIO_Pin_7, GPIO_Mode_In_FL_No_IT);
// de-initialize ADC
ADC_DeInit(ADC1);
// ADC configuration ---------------------------------------//
ADC_Init(ADC1, ADC_ConversionMode_Single,
ADC_Resolution_12Bit, ADC_Prescaler_1);
// SampleTime: 159 cycles
ADC_SamplingTimeConfig(ADC1,ADC_Group_SlowChannels, ADC_SamplingTime_384Cycles);
/* Enable ADC1 Channel 10*/
ADC_ChannelCmd(ADC1,ADC_Channel_10, ENABLE);
//ADC_VrefintCmd(ENABLE);
//ENABLE ADC1
ADC_Cmd(ADC1, ENABLE);
ADC_DMACmd(ADC1,ENABLE);
ADC_SoftwareStartConv(ADC1);
|