I couldn't generate 650khz with arduino mega
using write High,
write Low,
The highest frequency was 47khz,
even with arduino Uno,
pls help
I couldn't generate 650khz with arduino mega
using write High,
write Low,
The highest frequency was 47khz,
even with arduino Uno,
pls help
Try a different method:
byte PINx = XX; // where XX is whatever pin PORT D bit 2 is for example
void setup(){
pinMode (PINx, OUTPUT);
}
void loop (){
PIND = 0b0000100; // toggle PORT D bit 2 by writing a 1 to input register
}
650 KHz = 1.538uS, or 24.6 clocks not a lot of time to do much else.
You may also want to look into using a PWM output for this.
Thanks I ll try that too
It seems all my efort prove abortive, I couldn't generate the 650khz,
I think I need detailed help thanks
What frequency do you see with the PIND code?
I couldn't count any number of cycles on the PIND, maybe I couldn't fit in that sketch
I need more detail
In fact I do not generate frequency with PIND library,
I always generate square wave frequency by,
digitalWrite pin High and Low,
that's all
I don't know about PIND
Then your getting top speed for software only.
Anything more? if yes then
POST YOUR CODE!!!!!
Mark
If you put an infinite loop inside the loop function, you'll cut out all the serial "event" stuff in main.
Yes I generated 10khz with the delayMicrosecond (100),
When I have to make 650khz, I didn't delay it at all, but my top speed
Was only 47khz
ulobab:
When I have to make 650khz...
Precisely 650 kHz? If yes then you are not going to get it with a typical Arduino board. You can have...
16000000/(21(11+1)) = 666666.666667 Hz
...or you can have...
16000000/(21(12+1)) = 615384.615385 Hz
Which does not account for any inaccuracy in the resonator / crystal.
Edit: corrected the frequency possibilities
code CODE CODE CODE CODE CODE
Mark
Not exactly 650khz but anything close, 640khz is ok , as well as 660khz ,
how can I generate that with my Uno, I need help with complete sketch
thanks
ulobab:
how can I generate that with my Uno
Configure a timer (timer 1 or timer 2) to run in CTC mode with a prescaler of 1 and an appropriate TOP value. Don't forget to change the pin to an output.