120 khz output program wave question?

Hi im using this program to generate a 120 khz frequency.. I asked a question before http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1236217277/5#5 but it got lost. So if you can upload this program and can see if it is a square wave and if its not recommend how i can make a square wave at 120 khz with arduino... thanks uint8_t outPin = 2;

void setup() { pinMode(outPin, OUTPUT); digitalWrite(outPin, LOW); }

void loop() { digitalWrite(outPin, HIGH); // sets the pin on asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); digitalWrite(outPin, LOW); // sets the pin off asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); asm volatile("nop"); }

On my scope it reads 121.2 kHz and looks like it is LOW for slightly longer than it is High. How accurate a frequency, and how square of a square wave do you need ? Did you try this code in whatever application you had in mind? Don't forget that because of the way DigitalWrite works, this code will change freqeuncy if you move it to a PWM pin (like pin 3)

Are you asking similar questions in multiple threads? this seems to be asking for similar information: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1237689708/0#0

I tested your sketch as well and I get 121khz and 3% of the cycles fail... meaning that 3% of the cycles are completely out of sync.

The LOW measured 4.48uS, while HIGH mesured 3.76uS. It stays longer in LOW state because of the loop code to get to the next HIGH state.

What is the use case for this 120khz generator?