Starting ADC1 by hardware trigger on STM32F103

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Starting ADC1 by hardware trigger on STM32F103

Post by Giovanni »

What debugger are you using? In chibistudio there is a registers inspector for the STM32.

Giovanni
joewa
Posts: 22
Joined: Tue May 13, 2014 10:40 pm

Re: Starting ADC1 by hardware trigger on STM32F103

Post by joewa »

Hi!
I have to admit I am still a Chibios-Newbie and I didn't know about Chibistudio before...
My (actual) configuration is:
  • Ubuntu Linux 14.04 with "standard" Eclipse with CDT from the Ubuntu repository
  • STlink V2 from STM32F3-Discovery with BLACK MAGIC PROBE firmware from https://github.com/gsmcmullin/blackmagic.git
  • Debugger-Software: arm-none-eabi-gdb from launchpad
  • I am using an about 2-month old clone from Chibios 3.0
I can do everything like setting breakpoints at runtime, even with conditions, inspecting the stack trace, watching variables. But watching for example TIM3->CNT does not work for some reason.

Hm, how to get that "STM32 registers inspector" to my Eclipse? I would rather keep it because everyting else is working fine so far.

Jörg
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Starting ADC1 by hardware trigger on STM32F103

Post by Giovanni »

Hi,

You can find it here: https://sourceforge.net/projects/embsysregview/
Great project.

Giovanni
joewa
Posts: 22
Joined: Tue May 13, 2014 10:40 pm

Re: Starting ADC1 by hardware trigger on STM32F103

Post by joewa »

Hi,

Embsysregview is awesome!
Just in case somebody still tries to make it work, I found this useful post in the embsysregview forum:
in my investigation i found out that when you use eclipse >=3.6.x you are
using CDT >=7.x.

i guess you are using the "C/C++ GDB Hardware Debugging" component of CDT for
debugging your device.

CDT 7.x comes with a new interface (DSF-GDB) to GDB that is enabled by
default.

You have to switch to the old CDI/MI interface instead of the new in CDT 7.0.

You can do this in the Debug Configuration under GDB Hardware Debugging ->
Your Configuration -> Main Tab-> on the bottom "Using GDB (DSF) Hardware
Debugging Launcher" - Select other...

Click on "Select other..." and select "Standard GDB Hardware Debugging
Launcher"

The View is not prepared for the new interface and therefore get no
notification about suspend events, therfore cannot update the registers when
it sould have.
-Robert

I didn't solve my original problem of starting ADC1 by hardware trigger, but I will keep on trying...
At least I guess I understood now, that configirung EGR for that purpose is useless, because it is for software triggering the update event, isn't it?

Jörg
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Starting ADC1 by hardware trigger on STM32F103

Post by Giovanni »

You could use the GPT driver for triggering BTW.

Giovanni
joewa
Posts: 22
Joined: Tue May 13, 2014 10:40 pm

Re: Starting ADC1 by hardware trigger on STM32F103

Post by joewa »

Hi,

I already tried to use the GPT driver. In principle, this worked fine (calling adcStartConversion from the callback).
But unfortunately, this approach doesn't fit for my application: For the motor power electronics need very precise timing between the IGBT gate control signal and the ADC measurement. Using the GPT driver has too much jitter.

Now, I tried to trigger the ADC conversion by EXTERNAL software trigger (instead of using TRGO of TIM3 in case my implementation is wrong).
This is the configuration of the conversion group

Code: Select all

static const ADCConversionGroup adc_commutate_group = {
      TRUE, // circular mode
      ADC_COMMUTATE_NUM_CHANNELS,
      adc_commutate_cb,
      adc_commutate_err_cb,
      0, // ADC_CR1
      ADC_CR2_EXTTRIG | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 , // ADC_CR2: use ext event | select SWSTART event
      0, // ADC_SMPR1
      ADC_SMPR2_SMP_AN0(ADC_SAMPLE_1P5), // ADC_SMPR2
      ADC_SQR1_NUM_CH(ADC_COMMUTATE_NUM_CHANNELS), // ADC_SQR1
      0, // ADC_SQR2
      ADC_SQR3_SQ1_N(ADC_CHANNEL_IN0) // ADC_SQR3
};

Trying to start the conversion by:

Code: Select all

adcStartConversion(&ADCD1, &adc_commutate_group, commutatesamples, ADC_COMMUTATE_BUF_DEPTH);
ADC1->CR2 = ADC1->CR2 | ADC_CR2_SWSTART;  // Trigger the conversion!
doesn't work...

If I disable the external trigger configuration in the conversion group by replacing "ADC_CR2_EXTTRIG | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0)" by "0", the conversion is triggered immediately at adcStartConversion as it should (adc_commutate_cb is called).
But that is not what I want...

Although this looks very straightforward and I have no idea whats wrong there :(

Jörg
Post Reply