AnsweredAssumed Answered

Macro expansion for ADC Regular channel sequence length wrong

Question asked by Wilko Lunenburg on Apr 20, 2018

In stm32f1xx_ll_adc.h the expansion for the the channel seqence length omits shifting left  20 places the number of channels.


This is from the file:

__STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
  MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);


It expands to:

(((ADCx->SQR1)) = ((((((ADCx->SQR1))) & (~((0xFU << (20U))))) | (SequencerNbRanks))))


And thus OR's the SequencerNbRanks to the very end of the register, where it puts the number in the place of the 13th conversion in the regular sequence (I just need 1 channel, not 13)




And as the reference manual says that the number of channels in the sequence is SequencerNbRanks+1 shouldn't the number be decremented by one?