GPT set frequency

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

Moderator: RoccoMarco

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

Re: GPT set frequency

Post by Giovanni »

Could you look at TIM2 registers and post values here? especially the prescaler and ARR.

Giovanni
fastlink30
Posts: 42
Joined: Tue Aug 12, 2014 1:25 pm

Re: GPT set frequency

Post by fastlink30 »

attached register with all the values.
why tim2? gpt use tim8
if for irq priority i have already changed value for gpt8 (set to 11), but nothing change
tim8-gpt.png
tim8-gpt.png (4.64 KiB) Viewed 3288 times

tim2-pwm.png
tim2-pwm.png (4.61 KiB) Viewed 3288 times
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: GPT set frequency

Post by Giovanni »

Sorry :) the values of your timer of course.

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

Re: GPT set frequency

Post by Giovanni »

OK found the error....

I think you misunderstood the meaning of the frequency field in the configuration structure. It is not the frequency of the timer but the frequency driven into the timer counter (it is the resolution of the timer).

The final frequency, more appropriately the period, is what you pass to gptStartContinuous(), you set zero there and it is taken as 65536.

For example try setting the resolution to 1000000 (1uS) then pass to gptStartContinuous() the period you need in microseconds, for example 50 (20kHz).

Note that the PWM and ICU drivers work the same way.

It was obvious and in full sight yet perfectly invisible...

Giovanni
fastlink30
Posts: 42
Joined: Tue Aug 12, 2014 1:25 pm

Re: GPT set frequency

Post by fastlink30 »

ahaaa :D
now it's clear! :roll:

sorry giovanni for your time & patience

thank you
Post Reply