Page 1 of 1

stm32f37x sdadc timer trigger support

Posted: Tue Nov 01, 2016 9:05 pm
by noah
Hi all

The SDADC on the stm32f37x supports timer triggering, e.g. trigger SDADC3 from TIM12_CH2. There is no implementation in HAL 16 for enabling timer triggering, has someone done that before? The only option i see now would be to disable ADC HAL and do everything by hand...

Thanks for the reply
Cheers

Re: stm32f37x sdadc timer trigger support

Posted: Tue Nov 01, 2016 10:20 pm
by Giovanni
Hi,

Can't it be enabled by setting properly CR2 in the group configuration structure? is there something missing?

Giovanni

Re: stm32f37x sdadc timer trigger support

Posted: Wed Nov 02, 2016 2:58 pm
by noah
but there is no routine for initializing a timer channel for output compare when using the timer as GPT, is there?

Re: stm32f37x sdadc timer trigger support

Posted: Wed Nov 02, 2016 3:13 pm
by Giovanni
Hi,

GPT is only able to generate TRGO events, SDADC cannot use TRGO for some reason, you could use the PWM driver which uses output compare events for the de-activation front.

Giovanni

Re: stm32f37x sdadc timer trigger support

Posted: Thu Nov 03, 2016 10:26 pm
by noah
Finally figuered it out:

Code: Select all

#define SDADC_CR2_JEXTSEL_M(n)  ((n)<<8)
#define SDADC_CR2_JEXTEN_M(n)    ((n)<<13)
static const ADCConversionGroup adcgrpcfg1 = {
  TRUE, // circular
  ADC_GRP1_NUM_CHANNELS, // num_channels
  adccallback, // end_cb
  adcerrorcallback, // error_cb
  .u.sdadc = {
    /* CR2: select rising edge of TIM12_CH2*/
    SDADC_CR2_JEXTSEL_M(0x02) | SDADC_CR2_JEXTEN_M(0x01), // thats the important stuff
    SDADC_JCHGR_CH(ADC_GRP1_CHANNEL),
    {                       
      SDADC_CONFCHR1_CH6(0), //
      SDADC_CONFCHR1_CH6(0), // use configuration 0 for channel 6
    }
  }
};


then simply just start the correct timer as PWM output (PWMD2 CH4 in my case) and launch a continous conversion using adcStartConversion and you're good.

Thanks for the hint @Giovanni!