Sampling Problem, help!

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
francie84
Posts: 3
Joined: Wed Feb 07, 2018 4:12 pm

Sampling Problem, help!

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Sampling Problem, help!

Post 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
User avatar
RoccoMarco
Posts: 655
Joined: Wed Apr 24, 2013 4:11 pm
Has thanked: 83 times
Been thanked: 67 times

Re: Sampling Problem, help!

Post 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.
User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times

Re: Sampling Problem, help!

Post 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.
Post Reply