Getting started with the STM32F072B-Discovery

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

Moderator: RoccoMarco

DGW
Posts: 47
Joined: Fri May 30, 2014 9:14 am

Re: Getting started with the STM32F072B-Discovery

Post by DGW »

Good afternoon.
I am trying to run a survey of channel DSA event timer GPT3. Once I enter into an interrupt void adccb () and all though the timer is running.

ADC configuration:
const ADCConversionGroup adcgrpcfg1 = {
.circular = FALSE,
.num_channels = 1,
.end_cb = adccb,
.error_cb = adcerrorcallback,
.cfgr1 = ADC_CFGR1_EXTSEL_SRC (3) | ADC_CFGR1_EXTEN_FALLING | ADC_CFGR1_RES_12BIT | ADC_CFGR1_DISCEN,
.tr = ADC_TR (0, 0)
.smpr = ADC_SMPR_SMP_1P5,
.chselr = ADC_CHSELR_CHSEL10
};

Configuration Timer3:
GPT Config TImer Cfg =
{
.frequency = 1000000, // Timer Clock Freq in Hz
.callback = NULL, // Timer3CB, // Timer callback function
.cr2 = TIM_CR2_MMS_1,
.dier = 0
};

What could be wrong? A soft launch of ADC works.
Thank you for the help.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Getting started with the STM32F072B-Discovery

Post by Giovanni »

Hi,

There is a demo about GPT+ADC for the F7 in the repository, see if that gives you an hint, I don't see anything obviously wrong.

Giovanni
DGW
Posts: 47
Joined: Fri May 30, 2014 9:14 am

Re: Getting started with the STM32F072B-Discovery

Post by DGW »

Can I use this mode of ADC with the following parameters:
#define ADC_GRP1_NUM_CHANNELS 1
#define ADC_GRP1_BUF_DEPTH 1
???
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Getting started with the STM32F072B-Discovery

Post by Giovanni »

Yes.

Giovanni
DGW
Posts: 47
Joined: Fri May 30, 2014 9:14 am

Re: Getting started with the STM32F072B-Discovery

Post by DGW »

It does not work, even though it feels like you. Upon entering the interrupt handler (adcb) look at the contents of the register of CR and see what ADSTART bit = 0 (reset).
DGW
Posts: 47
Joined: Fri May 30, 2014 9:14 am

Re: Getting started with the STM32F072B-Discovery

Post by DGW »

Everything is working. I have had
.circular = FALSE, and it is necessary
.circular = TRUE,
Thank you!
DGW
Posts: 47
Joined: Fri May 30, 2014 9:14 am

Re: Getting started with the STM32F072B-Discovery

Post by DGW »

Good afternoon.
Connected to the input STM32F072C8 GPIOA1 source voltage and try to measure it with the ADC. To measure some nonsense, but not what I connect. But if I measure the same input voltage GPIOB1, all measured well. What could be the inlet GPIOA1?
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Getting started with the STM32F072B-Discovery

Post by Giovanni »

Is the pin programmed as analog input?

Giovanni
DGW
Posts: 47
Joined: Fri May 30, 2014 9:14 am

Re: Getting started with the STM32F072B-Discovery

Post by DGW »

Yes,

const ADCConversionGroup adcgrpcfg1 = {
.circular = TRUE, // FALSE,
.num_channels = 1,
.end_cb = adccb, // NULL,
.error_cb = adcerrorcallback,
.cfgr1 = ADC_CFGR1_EXTSEL_SRC (3) | ADC_CFGR1_EXTEN_RISING | ADC_CFGR1_RES_12BIT | ADC_CFGR1_DISCEN,
.tr = ADC_TR (0, 0)
.smpr = ADC_SMPR_SMP_13P5,
.chselr = ADC_CHSELR_CHSEL1
};
...
palSetPadMode (GPIOA 1, PAL_MODE_INPUT_ANALOG);

//does not work

or,

const ADCConversionGroup adcgrpcfg1 = {
.circular = TRUE, // FALSE,
.num_channels = 1,
.end_cb = adccb, // NULL,
.error_cb = adcerrorcallback,
.cfgr1 = ADC_CFGR1_EXTSEL_SRC (3) | ADC_CFGR1_EXTEN_RISING | ADC_CFGR1_RES_12BIT | ADC_CFGR1_DISCEN,
.tr = ADC_TR (0, 0)
.smpr = ADC_SMPR_SMP_13P5,
.chselr = ADC_CHSELR_CHSEL9
};
...
palSetPadMode (GPIOB, 1, PAL_MODE_INPUT_ANALOG);

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

Re: Getting started with the STM32F072B-Discovery

Post by Giovanni »

You should check obvious problems, is the pin unconnected on the board? Also check chip errata.

Giovanni
Post Reply