2021-12-13 03:50 AM
I am working with BlueNRG LP.
I am acquiring 3 channels:
ADC_VINP0 (PB3)
ADC_VINM0 (PB2)
BATTERY.
I used and modified example of the "BlueNRG-LP Navigator" ADC_DMA.
I read ADC_VINP0 and the batteries but ADC_VINM0 not work!! ( I used STEVAL-IDB011V1 and i remove the "R50" (pin DOUT of MP34DT05-A digital microphone)
static void MX_ADC_Init(void)
{
/* Enable the ADC peripheral */
HAL_ADC_StructInit(&adc_handle);
adc_handle.Init.DataRatio = USER_RATIO;
adc_handle.Init.DataWidth = USER_DATAWIDTH;
adc_handle.Init.SampleRate = USER_SAMPLERATE;
adc_handle.Init.SamplingMode = ADC_SAMPLING_AT_START;
adc_handle.Init.SequenceLength = ADC_SEQ_LEN_03;
adc_handle.DMA_Handle = &hdma_adc;
if (HAL_ADC_Init(&adc_handle) != HAL_OK) {
Error_Handler();
}
/* Set the 1 input channel */
xChannel.ChannelType = ADC_CH_VINP0_TO_SINGLE_POSITIVE_INPUT;
xChannel.SequenceNumber = ADC_SEQ_POS_01;
xChannel.VoltRange = ADC_VIN_RANGE_3V6;
if (HAL_ADC_ConfigChannel(&adc_handle, &xChannel)!= HAL_OK) {
Error_Handler();
}
/* Set the 2 input channel */
xChannel.ChannelType = ADC_CH_VINM0_TO_SINGLE_NEGATIVE_INPUT;
xChannel.SequenceNumber = ADC_SEQ_POS_02;
xChannel.VoltRange = ADC_VIN_RANGE_3V6;
if (HAL_ADC_ConfigChannel(&adc_handle, &xChannel)!= HAL_OK) {
Error_Handler();
}
/* Set the 3 input channel */
xChannel.ChannelType = ADC_CH_BATTERY_LEVEL_DETECTOR;
xChannel.SequenceNumber = ADC_SEQ_POS_03;
xChannel.VoltRange = ADC_VIN_RANGE_3V6;
if (HAL_ADC_ConfigChannel(&adc_handle, &xChannel)!= HAL_OK) {
Error_Handler();
}
LL_ADC_SetCalibPoint1Gain(ADC, LL_ADC_DEFAULT_RANGE_VALUE_3V6);
LL_ADC_SetCalibPointForSinglePos3V6(ADC, LL_ADC_CALIB_POINT_1);
}
/**
* Enable DMA controller clock
*/
static void MX_DMA_Init(void)
{
/* DMA controller clock enable */
__HAL_RCC_DMA_CLK_ENABLE();
/* Configure NVIC for DMA */
HAL_NVIC_SetPriority(DMA_IRQn, 0);
HAL_NVIC_EnableIRQ(DMA_IRQn);
}
2021-12-13 06:06 AM
> ADC_VINM0 not work
What about it doesn't work? What results are you getting and what do you expect instead?
2021-12-13 07:39 AM
i found the problem, i got confused with the HAL and LL drivers