72 MHz dividing by 100 code

What are you developing?
ted
Posts: 62
Joined: Sun Jul 16, 2017 9:57 pm

Re: 72 MHz dividing by 100 code

Post by ted » Tue Jan 02, 2018 6:11 pm

i will try that
You may combine both to get 720k/7k on PA7/6.

ted
Posts: 62
Joined: Sun Jul 16, 2017 9:57 pm

Re: 72 MHz dividing by 100 code

Post by ted » Tue Jan 02, 2018 6:12 pm

Thanks again

User avatar
Pito
Posts: 1734
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: 72 MHz dividing by 100 code

Post by Pito » Tue Jan 02, 2018 6:20 pm

PA7/PA6 - nope, see my previous source..
You cannot combine Timer3 with 2 different pwm periods it seems.
You need two different timers as I have done above.. it works with PA7/PA3.. :)
See the TimerX/ChannelY allocation - PWM3/2 means Timer3->Channel2:
.
STM32 BLuePill PIN diagram.JPG
STM32 BLuePill PIN diagram.JPG (209.41 KiB) Viewed 85 times
.
Each Timer has got 1 Auto-reload register - that is how the PWM "Period" is generated.
Each Timer has got 4 Compare regs - one for each Channel - that is how the "Duty" (the duration of H pulse within the Period) is generated.

Therefore you cannot have a Timer with 2 different Periods.
You may have 1 Timer with a "Period" and with 4 different "Duty ratios == pwm" - one duty for each Channel (== PinXY).
Pukao Hats Cleaning Services Ltd.

ted
Posts: 62
Joined: Sun Jul 16, 2017 9:57 pm

Re: 72 MHz dividing by 100 code

Post by ted » Tue Jan 02, 2018 6:42 pm

just merge the above c-sources together
I will try that.
The last your code, PA7 = OK, PA6 = no signal

User avatar
Pito
Posts: 1734
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: 72 MHz dividing by 100 code

Post by Pito » Tue Jan 02, 2018 6:44 pm

The Merged sources: viewtopic.php?f=19&t=3037&start=10#p39347
Also read my above posts..
HTH
Last edited by Pito on Tue Jan 02, 2018 6:46 pm, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.

ted
Posts: 62
Joined: Sun Jul 16, 2017 9:57 pm

Re: 72 MHz dividing by 100 code

Post by ted » Tue Jan 02, 2018 6:46 pm

So I can pick up PWM2 ?

ted
Posts: 62
Joined: Sun Jul 16, 2017 9:57 pm

Re: 72 MHz dividing by 100 code

Post by ted » Tue Jan 02, 2018 7:12 pm

The Merged sources:
Is working perfect, I have 720 kHz and 7.2 kHz.
Thanks
Now I will take a close look to understand completely how this is working.

User avatar
Pito
Posts: 1734
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: 72 MHz dividing by 100 code

Post by Pito » Tue Jan 02, 2018 7:17 pm

Look at the picture with PWM pin's allocations, and simply pick up the Timer and the Channel for the specific pin you want to use.
Some PWM TimerX/ChannelY pins are doubled - that means they can be remapped by sw.
Last edited by Pito on Tue Jan 02, 2018 7:36 pm, edited 1 time in total.
Pukao Hats Cleaning Services Ltd.

ted
Posts: 62
Joined: Sun Jul 16, 2017 9:57 pm

Re: 72 MHz dividing by 100 code

Post by ted » Tue Jan 02, 2018 7:23 pm

Of Course, I think I can do that.
There are nice people on the forum, just hard is to meet them.

ted
Posts: 62
Joined: Sun Jul 16, 2017 9:57 pm

Re: 72 MHz dividing by 100 code

Post by ted » Tue Jan 02, 2018 8:38 pm

The timer has 4 PWM outputs;
1. For square wave we can use HIGH/LOW on pin instead PWM ?
2. One of PWM can generate sine wave on additional pin?

Post Reply