stm32f37x sdadc timer trigger support

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

stm32f37x sdadc timer trigger support

Postby noah » Tue Nov 01, 2016 9:05 pm

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

Re: stm32f37x sdadc timer trigger support

Postby Giovanni » Tue Nov 01, 2016 10:20 pm

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

Postby noah » Wed Nov 02, 2016 2:58 pm

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

Re: stm32f37x sdadc timer trigger support

Postby Giovanni » Wed Nov 02, 2016 3:13 pm

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

Postby noah » Thu Nov 03, 2016 10:26 pm

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!


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 3 guests