/* Start ADC group regular conversion */
/* Note: Hardware constraint (refer to description of the functions */
/* below): */
/* On this STM32 series, setting of this feature is conditioned to */
/* ADC state: */
/* ADC must be enabled without conversion on going on group regular,*/
/* without ADC disable command on going. */
/* Note: In this example, all these checks are not necessary but are */
/* implemented anyway to show the best practice usages */
/* corresponding to reference manual procedure. */
/* Software can be optimized by removing some of these checks, if */
/* they are not relevant considering previous settings and actions */
/* in user application. */
if ((LL_ADC_IsEnabled(ADC1) == 1) &&
(LL_ADC_IsDisableOngoing(ADC1) == 0) &&
(LL_ADC_REG_IsConversionOngoing(ADC1) == 0) )
{
LL_ADC_REG_StartConversion(ADC1);
}
else
{
/* Error: ADC conversion start could not be performed */
Error_Handler();
}
/* Toggle LED at each ADC conversion */
LED_On();
LL_mDelay(LED_BLINK_SLOW);
LED_Off();
LL_mDelay(LED_BLINK_SLOW);
/* Note: ADC group regular conversions data are stored into array */
/* "uhADCxConvertedData" */
/* (for debug: see variable content into watch window). */
/* Note: ADC conversion data are computed to physical values */
/* into array "uhADCxConvertedData_Voltage_mVolt" using */
/* ADC LL driver helper macro "__LL_ADC_CALC_DATA_TO_VOLTAGE()" */
/* (for debug: see variable content with debugger) */
/* If ADC conversions and DMA transfer are completed, then process data */
if(ubDmaTransferStatus == 1)
{
/* Update status variable of DMA transfer */
ubDmaTransferStatus = 0;
/* Computation of ADC conversions raw data to physical values
using LL ADC driver helper macro. */
for (tmp_index = 0; tmp_index < ADC_CONVERTED_DATA_BUFFER_SIZE; tmp_index++)
{
tmp_value = __LL_ADC_CALC_DATA_TO_VOLTAGE(VDDA_APPLI, uhADCxConvertedData[tmp_index], LL_ADC_RESOLUTION_12B);
vf = (float)tmp_value /1000;
memset(buffer,0,20);
snprintf(buffer,20,"Value= %f\n\r",vf);
tmp_index = 0;
while(buffer[tmp_index] != '\0' && tmp_index < 20)
{
while(!LL_USART_IsActiveFlag_TXE(USART2));
LL_USART_TransmitData8(USART2,(uint8_t )buffer[tmp_index]);
tmp_index++;
}
}
LED_Toggle();
LL_mDelay(500); /* Delay to highlight toggle sequence */
}
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
|