cancel
Showing results for 
Search instead for 
Did you mean: 

Macro expansion for ADC Regular channel sequence length wrong

Willunen
Associate III
Posted on April 20, 2018 at 10:09

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)

0690X00000604CkQAI.jpg

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?

0690X00000604aMQAQ.jpg

0 REPLIES 0