AnsweredAssumed Answered

Bit banging timer problem

Question asked by jan_k on Jul 24, 2015
Latest reply on Jul 24, 2015 by Clive One

this is my first post here, so I'll start with some background information. My name is Jan and I've been working with the STM32 F407 for a few month now. This forum really helped me a lot and so far I was able to solve any problems I had with your help, for which I'd like to thank you all! :)

I'm currently trying to add a bitbanging function for a rgb LED. I already wrote a 1wire connection, which was no problem, so I thought this is an easy thing, but I'm struggling with the required speed.
All I needed is a different timer config, because the given period length is 1.25us in which I need a high and low signal. Since the GPIOs need about 100ns to reach the steady state, I was aiming for a timer tick frequency of 10MHz, however I can't get above 2,5MHz.
For the prescaler calculation I use the formula
prescaler = (timer default frequency (168MHz) / (period * frequency)) - 1
The formula works for every lower frequency, so probably it's a hardware limitation I'm not aware of.
I would provide the code, but it's really just a simple timer, so it probably wouldn't help.

I'm aware that there are other solutions like PWM or inline assembler, but I still wonder why it doesn't work.

Thanks in advance, I appreciate every help that I can get!

Edit: To clarify, my prescaler for 2,5MHz is 33, which is correct, but if I go down to 0 the frequency doesn't get higher than 2,8MHz, so the 2,5MHz is the last value were my formula works.
I'm measuring the frequency with an GPIO Pin, which is toggled each time the timer update interrupt occurs, could that be a problem?