AnsweredAssumed Answered

How to get the best ADC data?

Question asked by mich.lei on Jul 6, 2015
Latest reply on Jul 6, 2015 by mich.lei
I am testing/playing with a STM32f207 dev. board. I would like to know what ways are there to get most out of the ADC converter. For instance, is it possible to shut down the rest of CPU when conversion is done. Is there something ARM or ST specific I should know or are there any mistakes I made. The code below is mostly from the CubeMX.

The PC board is of course important and a dev. kit is not optimized for analog signals. Output wanders now between 0 and 3 and there are random high glitches. But some of it comes surely from the PCB.

The program below calculates an average of two conversions.
    #include "stm32f2xx_hal.h"
    #include <string.h>
    #include <stdio.h>
    #include <stdlib.h>
    /* USER CODE BEGIN Includes */
    char plaa[] = "Hellogffgffgf";
    char klaa[20];
    /* USER CODE END Includes */
    float ***,ccc;
    int b,c;
    /* Private variables ---------------------------------------------------------*/
    ADC_HandleTypeDef hadc1;
    UART_HandleTypeDef huart3;
    void SystemClock_Config(void);
    static void MX_GPIO_Init(void);
    static void MX_ADC1_Init(void);
    static void MX_USART3_UART_Init(void);
    int main(void)
        /* Configure the system clock */
        /* Initialize all configured peripherals */
        while (1)
        /* USER CODE END WHILE */
            HAL_ADC_Start(& hadc1);
            while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
    ccc= HAL_ADC_GetValue(&hadc1);
                    HAL_ADC_Start(& hadc1);
            while (HAL_OK!=         HAL_ADC_PollForConversion(&hadc1, 1000))
    ccc= HAL_ADC_GetValue(&hadc1)+ccc;
    sprintf (klaa,"readout %f \n", ***);
        //  strcpy(klaa,b);
    HAL_UART_Transmit(&huart3,(uint8_t *) klaa,c,1000);
        /* USER CODE BEGIN 3 */
            HAL_UART_Receive(&huart3, (uint8_t *)klaa, sizeof(klaa), 1000);
                HAL_UART_Transmit(&huart3,(uint8_t *) klaa,c,1000);