Hi,
I want to create a 10 mhz clock output without delaying, and have done this so far:
void loop() {
double t = millis();
// 10mhz cycle. half of the cycle is 5v the other is 0v:
if(t - tslc > 0.00005 && !cs)
{
if(!cs)
{
digitalWrite(XCLK_pin, HIGH);
cs = true;
}
else
{
digitalWrite(XCLK_pin, LOW);
cs = false;
}
tslc = millis();
}
}
accidently posted the thread before i was finished writing..
so my question is, if what I've done so far could provide a steady 10mhz clock or if the arduino uno is too slow for this?
any help or discussion is very much appreciated, thanks
regards
søren
Ten milliHertz is one tick every 100 seconds.
I think a 16MHz processor can tackle that.
double t = millis();
I'm happy to see that you can RTFM.
He wants 10 mhz, as in, megahertz.
Not 10 millihertz (whatever did you get that idea? )
Can't be done on 16mhz uno - you can get 16, and you can get 8, but not 10 (though you could get it from an avr clocked at 20mhz.
Also, OP: numbers used by all the library functions take and return integers unless they specifically work with floats (the timekeeping ones certainly don't)
You can't get a 10 MHz output with a 16 MHz clock. You could get a 10 MHz clock by running your Arduino at 20 MHz. To do that you should buy a 20 MHz Arduino clone (none of the genuine Arduinos run at 20 MHz). An alternative would be to change the 16 MHz resonator to a 20 MHz one but that requires some tricky surface-mount soldering.