LibSamples_MM32F0140_V1.3.7
hal_adc.c
void ADC_RegularChannelConfig(ADC_TypeDef* adc, u32 channel, u8 rank, u32 sample_time) //ADCSAM_TypeDef
{
u32 tempchan;
sample_time = sample_time & 0xF;
tempchan = channel;
if(tempchan > 8)
{
tempchan = tempchan & 0xF;
tempchan = tempchan - 8;
adc->SMPR2 &= ~(0xF << (tempchan << 2));
adc->SMPR2 |= (sample_time << (tempchan << 2));
}
else
{
adc->SMPR1 &= ~(0xF << (tempchan << 2));
adc->SMPR1 |= (sample_time << (tempchan << 2));
}
}
官方的代码如上述,我觉得这个判断有问题,大于8才走SPMR2寄存器,实际序号是0-7,8-15,那么序号8就被装入了SMPR1了,这是不是错误? |