Page 1 of 1

Sampling Problem, help!

Posted: Wed Feb 07, 2018 4:46 pm
by francie84
Hi there!
i'm currently using the last available ChibiStudio release (With ChibiOS eclipse tools 2.5.0) and a STM32F401RE Nucleo board, i quite like them and i'd like to learn more.
Actually i'm getting problems with sampling: what i'd like to do is to sample two different signals from A0-A1 pins.
I read it's not possible to do that simultaneously with this board but sequentially.
I wrote some code but it isn't working properly, i mean it looks like the adc only reads the voltage on A0.
The demo i'm following is this: http://www.playembedded.org/blog/wp-con ... PT-ADC.zip

I modified that code in this way:

Code: Select all

static const ADCConversionGroup adcgrpcfg1 = {
  true,
  ADC_GRP1_NUM_CHANNELS,
  adccallback,
  adcerrorcallback,
  0,                                                            /* CR1 */
  ADC_CR2_EXTEN_0 | ADC_CR2_EXTSEL_3,                          /* CR2 */
  ADC_SMPR2_SMP_AN0(ADC_SAMPLE_144) | ADC_SMPR2_SMP_AN1(ADC_SAMPLE_144),/* SMPR1 */
  0,                                                            /* SMPR2 */
  ADC_SQR1_NUM_CH(ADC_GRP1_NUM_CHANNELS),                       /* SQR1 */
  0,                                                            /* SQR2 */
  ADC_SQR3_SQ1_N(ADC_CHANNEL_IN0) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN1)/* SQR3 */
};


then added some chprintf instructions in order to see values on my terminal. Where am i wrong?

Thank you for your time.

Re: Sampling Problem, help!

Posted: Wed Feb 07, 2018 6:28 pm
by Giovanni
You need to post all the related code, just the structure is not sufficient. Why those EXTSEL settings?

Have you looked at the demo under /testhal/STM32/STM32F4xx/ADC ?

Giovanni

Re: Sampling Problem, help!

Posted: Wed Feb 07, 2018 8:24 pm
by RoccoMarco
Hello there,
please post the whole main if it is possible

Giovanni wrote:Why those EXTSEL settings?

Giovanni, because the demo He is using is the GPT-ADC one.

Re: Sampling Problem, help!

Posted: Wed Feb 07, 2018 9:18 pm
by wurstnase
ADC_SQR3_SQ1_N(ADC_CHANNEL_IN0) | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN1)

This is wrong. Each conversion has it's own sequence. Please check the reference manual and testhal for it.