cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Discovery Help!

kotoel26
Associate II
Posted on May 07, 2013 at 21:15

Hi guys, im trying to use the ADC on my board, but i have a problem,  after  enable the ADC (ADON=1 ),i have to put ADONS=1 to start the convertion,and i dont know how!?,

i was reading the datasheet and tu put ADONS=1 is for hardware, really i need help.

:( 

#discovery #board #incomplete #which-discovery-board? #adc #adc #discovery #board
5 REPLIES 5
Posted on May 07, 2013 at 22:44

On which Discovery, with what chip? Figure around half a dozen different ones.

Pretty much all of them you need to light off once you have everything configured.

  /* Start ADC1 Software Conversion */

  ADC_SoftwareStartConv(ADC1);

Suggest you review the firmware library and example.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kotoel26
Associate II
Posted on May 08, 2013 at 00:59

the chip is STM32L152xD , check my code :)

ADC_CommonInitTypeDef ADC_CommonInitStructure;

ADC_InitTypeDef ADC_InitStructure;

LCD_Configuration();

RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);

/*Inizializar valores por default*/

ADC_DeInit(ADC1);

ADC_CommonStructInit(&ADC_CommonInitStructure);

/*Configuracion del Prescaler*/

ADC_CommonInitStructure.ADC_Prescaler=ADC_Prescaler_Div4;

ADC_CommonInit(&ADC_CommonInitStructure);

/*-Configuracion del ADC-*/

  ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;

  ADC_InitStructure.ADC_ScanConvMode = DISABLE;

  ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;

  ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;

ADC_InitStructure.ADC_ExternalTrigConv=ADC_ExternalTrigConv_T2_CC2;

  ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;

  ADC_InitStructure.ADC_NbrOfConversion = 1;

ADC_Init(ADC1,&ADC_InitStructure);

/* ADC1 regular channel 17 for VREF configuration */

  ADC_RegularChannelConfig(ADC1, ADC_Channel_17, 1, ADC_SampleTime_192Cycles);

ADC_RegularChannelConfig(ADC1, ADC_Channel_16, 1, ADC_SampleTime_192Cycles);

ADC_TempSensorVrefintCmd(ENABLE);

ADC_ContinuousModeCmd(ADC1, ENABLE); 

ADC_PowerDownCmd(ADC1, ADC_PowerDown_Idle_Delay, ENABLE);

/*Inicializar en ADC*/

ADC_Cmd(ADC1,ENABLE);

/* Wait until ADC1 ON status */

  while (ADC_GetFlagStatus(ADC1, ADC_FLAG_ADONS) == RESET)

  {

  }

ADC_SoftwareStartConv(ADC1);

  while (1)

  {

prueba=0;

prueba|=ADC_GetConversionValue(ADC1);

Print_LCD(prueba);

Delay_ms(500);

  }

Posted on May 08, 2013 at 02:21

Make sure to enable HSI prior to enabling the ADC clock on the APB

  /* Enable the HSI */

  RCC_HSICmd(ENABLE);

  /* Wait until HSI oscillator is ready */

  while(RCC_GetFlagStatus(RCC_FLAG_HSIRDY) == RESET);

Decide which of the channels, 16 or 17, you want to be sampling, as you've set it up for just 1 channel, then try and define 2.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kotoel26
Associate II
Posted on May 08, 2013 at 03:12

jajajaj thats right man!!, i forget the HSI , now works!!! ,Thanks man !!! ;)

kotoel26
Associate II
Posted on May 09, 2013 at 07:27

Hello again man, i have a problem :when i enable the Vefint the register no change i can see the register in debug mode, i check the code and is fine i dont know what happends! and is the same for de prescaler :s