Page 2 of 2

Re: Blue Pill counting number of pulses using timers

Posted: Wed Mar 18, 2020 1:36 pm
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

Re: Blue Pill counting number of pulses using timers

Posted: Wed Mar 18, 2020 1:38 pm
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

Re: Blue Pill counting number of pulses using timers

Posted: Wed Mar 18, 2020 1:56 pm
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.

Re: Blue Pill counting number of pulses using timers

Posted: Wed Mar 18, 2020 2:04 pm
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.

Re: Blue Pill counting number of pulses using timers

Posted: Wed Mar 18, 2020 7:23 pm
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!

Re: Blue Pill counting number of pulses using timers

Posted: Thu Mar 19, 2020 8:55 am
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-)