- This topic has 0 replies, 1 voice, and was last updated 7 years, 3 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
Home › Forums › Mastering STM32 book support forum › Question whose answer i couldn't find in book
Hello.
At first i want say thanks for book, it very helped, exactly what i searched.
But i have small question. ADC chapter is very good but now i’m studying code of STM 6Step library, it’s library from Cube Expansion SPN7, motor control. There is following code which i can’t understand (i can guess, and can study HAL code to understand, but may be somebody can explain this code:
void MC_SixStep_ADC_Channel(uint32_t adc_ch)
{
ADCx.Instance->CR |= ADC_CR_ADSTP;
while(ADCx.Instance->CR & ADC_CR_ADSTP);
/* Clear the old SQx bits for the selected rank */
ADCx.Instance->SQR1 &= ~__HAL_ADC_SQR1_RK(ADC_SQR2_SQ5, 1);
/* Set the SQx bits for the selected rank */
ADCx.Instance->SQR1 |= __HAL_ADC_SQR1_RK(adc_ch, 1);
ADCx.Instance->CR |= ADC_CR_ADSTART;
}
Ok, i understand they stop ADC, then wait it be stopped, then deselect channel ADC_SQR2_SQ5, then select channel sent through argument, and start ADC.
Questions is following:
1. Why do they need use low level access? Is there no HAL functions? What do they try achieve with using low level code?
2. If they select different channels calling each time this function, then why they always deselect ADC_SQR2_SQ5 only?
Thanks!