ADC conversion + Analog Watch Dog

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
Alex
Posts: 39
Joined: Sat Feb 22, 2014 2:40 pm
Been thanked: 3 times

ADC conversion + Analog Watch Dog

Post by Alex »

moved from the my previous topic
Same problem, another way

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, call adcerr_wdg, but not store results of conversion, (clear, ok)
if ADC_WDG_BUFDEPTH > 0, store results of conversion, but not call adcerr_wdg (why?) at the same conditions

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

clear up the point: I am interested in: store result of conversion at channel8 once of certain time period,
and check ranges of signal at channel9 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
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: ADC conversion + Analog Watch Dog

Post by Giovanni »

Hi,

Buffer depth == 0 is forbidden, you should not do that.

About the WDG, when a WDG condition is detected the conversion is stopped and the driver goes into the ADC_ERROR state, you need to restart the conversion. It is strange that you don't get the callback, are you sure about this? I will make some tests over weekend.

Giovanni
Alex
Posts: 39
Joined: Sat Feb 22, 2014 2:40 pm
Been thanked: 3 times

Re: ADC conversion + Analog Watch Dog

Post by Alex »

Giovanni wrote:It is strange that you don't get the callback, are you sure about this?


I will repeat my approaches too.
some corrections:

if field <adc_callback> == NULL getting <adcerr_wdg> is regular,
but else getting <adcerr_wdg> is very rarely;

i use this call conversion now

Code: Select all

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


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)}}};
Post Reply