stm32f37x sdadc timer trigger support

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
noah
Posts: 6
Joined: Wed Sep 28, 2016 8:09 pm
Been thanked: 2 times

stm32f37x sdadc timer trigger support

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

Re: stm32f37x sdadc timer trigger support

Post by Giovanni »

Hi,

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

Giovanni
noah
Posts: 6
Joined: Wed Sep 28, 2016 8:09 pm
Been thanked: 2 times

Re: stm32f37x sdadc timer trigger support

Post by noah »

but there is no routine for initializing a timer channel for output compare when using the timer as GPT, is there?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: stm32f37x sdadc timer trigger support

Post 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
noah
Posts: 6
Joined: Wed Sep 28, 2016 8:09 pm
Been thanked: 2 times

Re: stm32f37x sdadc timer trigger support

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