Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 11 months ago.
High speed clock signal From GPIO Nucleo
Hi there. I am looking for a little advice. First off i am using a Nucleo 401RE
I am after generating a 5Mhz clock signal using one of the GPIO ports. I have set up a ticker using.
t1.attach(&mClock, 0.00002); and mClock(){ { Clk = !Clk; line that is actioned every time the ticker is run. }
However the ticker will not operate at the speed i want it too I.e. 1 sec/5,000,000 Hz = 0.0000002; Is there any other tricks out there to achieve this? Also on the Nucleo are some of the GPIO faster then others?
Thanks John
1 Answer
9 years, 11 months ago.
Ticker has 1us time base, so less than that is not possible. Even at 1us the overhead might very well be too much to generate your signal, and for sure it would take pretty much all your processing power.
In addition it needs to run at 10MHz for a 5MHz output wave: It needs to toggle the output twice per period. Also all GPIO are same speed (at least from software POV, maybe some have faster edges, but won't help you here).
In general a better solution for a fixed output wave is PWM. However also PwmOut has 1us resolution. An alternative is: http://developer.mbed.org/users/Sissors/code/FastPWM/. which allows for the full resolution the hardware is capable of. In case of the F401 this is 84MHz divided by an integer: 84 / 17 = 4.94MHz is the closest it can get to 5MHz.
Thank you fro your reply. I think i am going to have too generate my clock signal externally I think. But i have one more question.
Okay I am generating a 5Mhz signal from a pulse generator. But I will also be generating a 1.6 Mhz signal too. Here is the question is the Nucleo's interrupt fast enough to detect the rising edge of this slower signal allowing me to read an analogue signal from another source.
The reason for all this is am trying to use my Nucleo with a Line scan sensor TCD132D
posted by 01 Dec 2014Simple answer: No.
Long answer, maybe just if you directly access all the peripherals, but definately not using the mbed libraries.
posted by 01 Dec 2014HI again Erik just another question. Just reading your previous post again regarding PWM speeds were did you get the value 17 from?? "84 / 17 = 4.94MHz is the closest it can get to 5MHz" what is your source of information Just so i can do some study my self.
Thanks John
posted by 01 Dec 2014PWM peripherals can only do integer divisions. 84MHz is the clock frequency of the F401, and generally the PWM can run at max this speed. Then it was just a matter of opening the calculator and trying integer divisions until I got close to 5MHz (obviously 84MHz/5MHz would also have given me the answer, but my method was more fun).
posted by 01 Dec 2014