Blue Pill counting number of pulses using timers

Post here all questions related to LibMaple core if you can't find a relevant section!
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Blue Pill counting number of pulses using timers

Post by stevestrong »

It is also possible with the current core you use (libmaple) if you know which register and which bit to set.
Here a short example: https://web.archive.org/web/20190317100 ... php?t=1153
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Blue Pill counting number of pulses using timers

Post by stevestrong »

I knew I have posted a similar example already somewhere.
Now i have found it: https://web.archive.org/web/20190316154 ... =18&t=3804
Last edited by stevestrong on Wed Mar 18, 2020 2:00 pm, edited 1 time in total.
Kovaxant
Posts: 7
Joined: Wed Mar 18, 2020 7:39 am

Re: Blue Pill counting number of pulses using timers

Post by Kovaxant »

stevestrong wrote: Wed Mar 18, 2020 1:38 pm I new I have posted a similar example already somewhere.
Now i have found it: https://web.archive.org/web/20190316154 ... =18&t=3804
Looking at your code with my ignorant eyes I must say that it looks to be the solution to my troubles. I do see

Code: Select all

 timer_init(TIMER2);
So which Library/Core is to be used to get this working?

Thank you very, very much.
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Blue Pill counting number of pulses using timers

Post by stevestrong »

It is the Libmaple (aka Roger's) core: https://github.com/rogerclarkmelbourne/Arduino_STM32
I think it is identical with the one installed from dan.drown.org.
[s]There you have TimerX.init(), too.[/s] ;) - this applies to F4 family only.
Kovaxant
Posts: 7
Joined: Wed Mar 18, 2020 7:39 am

Re: Blue Pill counting number of pulses using timers

Post by Kovaxant »

stevestrong wrote: Wed Mar 18, 2020 1:38 pm I knew I have posted a similar example already somewhere.
Now i have found it: https://web.archive.org/web/20190316154 ... =18&t=3804
Hurray!

It works with no modifications on Blue Pill!
When connected with a 9MHz PWM source it counts 9012 - 9013 pulses.
When connected to a digital audio FSCLK of 44100 Hz it counts 44-45, and counts for 96k and 192k is also off by just 1.
Perfect for my needs!
Thank you SO MUCH, you have (temporarily) saved me from going to the HAL jungle.

P.S. When you come to Croatia for u summer holidays, the dinner and drinks are on me. Give me a shout!
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Blue Pill counting number of pulses using timers

Post by stevestrong »

Kovaxant wrote: Wed Mar 18, 2020 7:23 pm P.S. When you come to Croatia for u summer holidays, the dinner and drinks are on me. Give me a shout!
Thanks, I may make use of this, after this Corona-madness is over. 8-)
Post Reply

Return to “General discussion”