Sampling Problem, help!

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

Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess

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

Sampling Problem, help!

Postby francie84 » Wed Feb 07, 2018 4:46 pm

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: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Sampling Problem, help!

Postby Giovanni » Wed Feb 07, 2018 6:28 pm

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
Location: Munich (Germany)
Has thanked: 83 times
Been thanked: 67 times
Contact:

Re: Sampling Problem, help!

Postby RoccoMarco » Wed Feb 07, 2018 8:24 pm

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.
Ciao,
RM

User avatar
wurstnase
Posts: 121
Joined: Tue Oct 17, 2017 2:24 pm
Has thanked: 43 times
Been thanked: 30 times
Contact:

Re: Sampling Problem, help!

Postby wurstnase » Wed Feb 07, 2018 9:18 pm

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.
\o/ Nico


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 26 guests