ADC1, GPT1/14 Conflict on STM32F0

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

Moderator: RoccoMarco

Post Reply
samtatasurya
Posts: 22
Joined: Sun Nov 29, 2015 8:13 pm

ADC1, GPT1/14 Conflict on STM32F0

Post by samtatasurya »

Hi everyone,

I'm using ChibiOS 16.1.4, and the board I'm using is STM32F0 Discovery (STM32F051R8).

I was trying to use both ADC and GPT, but when I was trying to run adcStartConversion() and gptStartContinuous() for the following pairs, my program stopped working:
- ADCD1, GPTD1
- ADCD1, GPTD14

Since I'm using my GPTD3 for other use, and ST requires GPTD2 (when I tried to use GPTD2 st_lld.c raised an error during compilation), I don't know what else to do.

Has anyone run into the same issue? Any suggestion on what to do?

Thanks!

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

Re: ADC1, GPT1/14 Conflict on STM32F0

Post by Giovanni »

Hi,

You can disable the tickless mode in chconf.h, this way TIM2 is free for other drivers, also put tick frequency to 1000.

Giovanni
samtatasurya
Posts: 22
Joined: Sun Nov 29, 2015 8:13 pm

Re: ADC1, GPT1/14 Conflict on STM32F0

Post by samtatasurya »

Giovanni wrote:Hi,

You can disable the tickless mode in chconf.h, this way TIM2 is free for other drivers, also put tick frequency to 1000.

Giovanni


Thank you for the suggestion, Giovanni.
Just to verify, does that mean if I put the tick frequency to 1000, the system tick boundary will be 1 mS? If originally it is 10000, does that mean the current tick boundary is 100 uS?

Also, is there any chance that I can still use the other GPTs (GPT 1 & 14) together with ADC 1?

One thing that I also notice is that the order of function call results in different behavior.

Case 1 results in the system being stuck around GPT function calls:

Code: Select all

adcStart(&ADCD1, NULL);
adcStartConversion(&ADCD1, &adcgrpcfg, samples, ADC_GRP_BUF_DEPTH);

gptStart(&GPTD3, &gpt3cfg);
gptStartContinuous(&GPTD3, GPT3_INTERVAL);


Whereas in case 2, all functions called successfully:

Code: Select all

gptStart(&GPTD3, &gpt3cfg);
gptStartContinuous(&GPTD3, GPT3_INTERVAL);

adcStart(&ADCD1, NULL);
adcStartConversion(&ADCD1, &adcgrpcfg, samples, ADC_GRP_BUF_DEPTH);


Your insight is greatly appreciated. :D

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

Re: ADC1, GPT1/14 Conflict on STM32F0

Post by Giovanni »

Correct about systick.

About ADC and GPT, I suggest to start driver first, the start conversion, then start the timer. The reason is hidden in the STM32 technical details and quirks.

Giovanni
Post Reply