Page 1 of 1

Start ADC Conversion from within ADC conversion callback

Posted: Thu Mar 10, 2016 11:16 am
by Alex
Can i call start adc conversion from within callback of previous adc conversion?
My approaches was unsuccessfull..

for example: (reconstruction, may be small errors)

Code: Select all

void adc1_callback(ADCDriver *adcp, adcsample_t *buffer, size_t n)
{
...
  adcStartConversionI(adcp, &adc_grp_cfg2, &sample_2, ADC_GRP2_NUM_CHANNELS);
...
}

// conversion group for previous conversion
static const ADCConversionGroup adc_grp_cfg1 = {
  FALSE,
  1,                                                                                                
  adc1_callback,                                                                               
  NULL,                                                                            
  .u.adc = {
      0, ADC_CR2_SWSTART, 0, 0,                                                                         
    { 0,     ADC_SMPR2_SMP_AN8(ADC_SAMPLE_1P5)},                                                
    { 0, 0,  ADC_SQR3_SQ1_N(ADC_CHANNEL_IN8 ) }
   }
};

// conversion group for next conversion
static const ADCConversionGroup adc_cfg_grp2 = {                                         
  FALSE,                                                                                                                        
  ADC_WDG_NUM_CHANNELS,                                                                                                   
  NULL,                                                                                                                         
  adcerr_wdg,                                                                                                                
  .u.adc = {                                                                           
    ADC_CR1_AWDEN | ADC_CR1_AWDIE | ADC_CR1_AWDSGL | ADC_CR1_AWDCH_0 | ADC_CR1_AWDCH_3,   
      ADC_CR2_SWSTART | ADC_CR2_CONT,                                                                               
      NEGATIVE_VOLTAGE_LIMIT,                                                                                             
      POSITIVE_VOLTAGE_LIMIT,                                                                                            
    { 0,     ADC_SMPR2_SMP_AN9(ADC_SAMPLE_1P5)},                                                            
    { 0, 0,  ADC_SQR3_SQ1_N(ADC_CHANNEL_IN9)}}};                                                            
                     



Re: Start ADC Conversion from within ADC conversion callbac

Posted: Thu Mar 10, 2016 11:44 am
by Giovanni
It should work. You are not defining "unsuccessful".

Giovanni

Re: Start ADC Conversion from within ADC conversion callbac

Posted: Thu Mar 10, 2016 12:00 pm
by Alex
Thank you!

To define "unsuccessfull" need too many words...

Re: Start ADC Conversion from within ADC conversion callbac

Posted: Thu Mar 10, 2016 1:18 pm
by Giovanni
Hi,

You should give a minimum of info when asking for support, at very least what you expect and what you are getting instead. Specifying also the device used, the ChibiOS version would be useful too.

Giovanni

Re: Start ADC Conversion from within ADC conversion callbac

Posted: Thu Mar 10, 2016 1:34 pm
by Alex
Sorry, but i don't wait no more anything..

Device - STM32F373C8T6, OS - Nil from ChibiOs 3.0

great respect !

Re: Start ADC Conversion from within ADC conversion callbac

Posted: Thu Mar 10, 2016 2:24 pm
by Giovanni
Hi,

It was not my intention to offend you, I just needed more info in order to give support.

Giovanni

Re: Start ADC Conversion from within ADC conversion callbac

Posted: Thu Mar 10, 2016 5:59 pm
by Alex
Same problem, other side look:

this conversion group:

Code: Select all

static const ADCConversionGroup adc_cfg_wdg2 = {                                        
  FALSE,                                                                                                                        
  2,                                                                                                   
  NULL,                                                                                                                         
  adcerr_wdg,                                                                                                                
  .u.adc = {                                                                           
    ADC_CR1_AWDEN | ADC_CR1_AWDIE | ADC_CR1_AWDSGL | ADC_CR1_AWDCH_0 | ADC_CR1_AWDCH_3,   
      ADC_CR2_SWSTART | ADC_CR2_CONT,                                                                               
      NEGATIVE_VOLTAGE_LIMIT,                                                                                             
      POSITIVE_VOLTAGE_LIMIT,                                                                                            
    { 0,     ADC_SMPR2_SMP_AN8(ADC_SAMPLE_1P5) | ADC_SMPR2_SMP_AN9(ADC_SAMPLE_1P5)},      
    { 0, 0,  ADC_SQR3_SQ2_N(ADC_CHANNEL_IN8)   | ADC_SQR3_SQ1_N(ADC_CHANNEL_IN9)}}};      


and this call conversion

Code: Select all

adcStartConversionI(&ADCD1, &adc_cfg_wdg2, buf, ADC_WDG_BUFDEPTH);


if ADC_WDG_BUFDEPTH > 0, store results of conversion, but not call adcerr_wdg
if ADC_WDG_BUFDEPTH == 0, call adcerr_wdg, but not store results of conversion, in same conditions

I want both actions: store results of conversion, and call adcerr_wdg - this is possible?

clear up a point: I am interested in: result of conversion at channel 8 once of certain time period,
and check ranges signal at channel 9 during whole this period

PS: Device STM32F373C8T6, board- self made, OS - NIL from ChibiOs v3.0
PPS: Sorry for my Engish ...

thank you very much for you tolerance