Page 1 of 1

ADC1, GPT1/14 Conflict on STM32F0

Posted: Tue Mar 22, 2016 7:33 am
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

Re: ADC1, GPT1/14 Conflict on STM32F0

Posted: Tue Mar 22, 2016 7:42 am
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

Re: ADC1, GPT1/14 Conflict on STM32F0

Posted: Tue Mar 22, 2016 7:59 am
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

Re: ADC1, GPT1/14 Conflict on STM32F0

Posted: Tue Mar 22, 2016 2:41 pm
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