Hi folks, I'm new to Arduino Due. I want to use Arduino Due to achieve more accurate timing, specifically in the range of 50 to 500 nanoseconds. I tried using the micros() function, but it can only handle intervals of 3 microseconds, and I'm getting very unstable values in my digital signal outputs. Do you have any solutions to help me figure this out? Thank you very much."
Sorry not using the method you describe, it is not fast enough.Interesting problem, how do you plan on sensing the signal and at what voltage? What additional hardware do you plan on adding? How accurate do you need to be? What math do you need to perform other then frequency?
What are you basing that on? Are you using an oscilloscope? If so, which one and how did you calibrate it?
Hi, I want to generate 3 signals, which are SPI2, Clock, Latch in code part. I want to generate a faster clock period. But I can only use micros() to generated the clock period, when I set BlinkClock(time period of the clock) below 15us, BlinkClock = 10 for example. The outputs of three signals are not stable, clock period is totally wrong and will have overlap on my Oscilloscope which show on figure 1
. When I use BlinkClock = 15, which is what I expected in Figure 2.
So I think the micros() is not accurate enough in my condition. Since I want to get clock period into 2Mhz. I believe Arduino Due are able to reach that fast. However, I have found the solution yet.
Yes, I'm using oscilloscope. I want to get a faster clock period and able to read my digital data for faster.
Then the key to finding that Arduino is to get one with the fastest clock. That should be part of the data sheet on the board.
Maybe get a Teensy 4.1......
600MHz
Actually, I don't know how to use the registers on the chip datasheet. I'm too beginner for this and I don't find examples on google and some examples are only for Arduino Uno which don't compile with Due.
should be Mega Hz
But your questions and requested help point to much more advanced experience. Something does not match up.
What is it that you want to control with that fast clock?
Do you actually have a need for it?
What is shorter? A few nano seconds or a microsecond? Your attempt will never work
You will have to study and learn; I only have experience with AVR boards so can't help.
Have you taken a look at the ESP32 or similar units?
Why don't you use HW-SPI? It's much more accurate regarding the timing.
That isn't really much for HW-SPI.
An attempt with micros() will never be accurate, because your other statements in the shifiting loop need time too.
Sorry, what's that? Do you have any link related about it?
No, I saw some Library that is for Arduino Uno to control up to 0.5us. The only thing I have is Arduino Due, so I'm trying to find some solution.
Yes for my current condition. So I have to find some function like micros() which can control the time around 500ns or even less.
Give us a link to that "I saw some Library " so we can check it out. I have code that would work, I just cannot find a processor that is fast enough. I highly recommend you spend some time and learn the basics of how the Arduino is configured and how the functions work. You will find that micros() and many other functions work because of background interrupts which is what is showing on your scope waveform.
Here is the link which is for Arduino Uno .
How to Get an Arduino Micros() Function With 0.5us Precision : 5 Steps - Instructables
Nice library but it is 1/10 of what you want.
@kelong8383, why haven't you addressed @MicroBahner's question??? This task can be done much better in hardware. Trying to do it with software makes no sense.