Running the sample "BLINK" program @ 16 MHz

Well, that pretty much says exactly what I want to do. Is this possible? Seems the PWM is limited in speed and I need to have the ability to set an output and a pause and repeat. This will allow me to run an extremely short on pulse of 1 to (oh let's say) 10 units and run an off interval of 1 to 10,000 or more and repeat. Simple as that, now how can I do it?

This will allow me to run an extremely short on pulse of 1 to (oh let's say) 10 units

And what are these mysterious units?

The chip runs one machine instruction 16 million times per second. You can't really expect to turn a pin on or off with a single machine instruction, so 16MHz PWM is wishful thinking.

Each "unit" is 62.5 nanoseconds or the reciprocal of 16 million. I have had input from others on Arduino forums implying this is possible

Your friend is the "nop" instruction

Underground - If you can get you program to execute 16 million times a second, YES, but what you need to understand is that the code to blink takes many instructions, ans thus there is no way you can get anywhere close.

If you write some really tight, dedicated code in assembly language you can get rid if all the extra instructions that are there from compiling the c code, then you can get the numbers higher for PWM frequency.

I took some stepper driver code from 1260 bytes to 88 bytes by coding in assembler.

The bottom line is what you want to do is possible but the program won't look anything like the blink sample code.

Ah-HA! ^^^(begins to see the light)^^^ U see, my good people, I have a wonderful great Invention I am attempting to bring to life. I guess what I really need to do is contract such a program and pay for it. OR get a "partner" as such. But at this time I just need the stripped down, bare bones coding that will accomplish such a feat of speed and accuracy.

Seems you all are telling me the Arduino reads and executes the Wiring language which slows it way down from it's absolute 16 MHz speed limit. Makes sense now. I need machine coding so the Arduino reads and executes Directly with no lag. ?

But at this time I just need the stripped down, bare bones coding that will accomplish such a feat of speed and accuracy.

You also need realistic expectations. Even with assembly language programming you can not toggle the pin on and off 16 million times a second.

To be fair, a 16 MHz toggle was not requested. At least, that's how I read it.

Apologies for the possible thread-jack, but there is a physical limitation as to how "fast" the eye can see. I've seen different numbers, but let's say the eye can't register anything faster than 60 blinks per second.

Can the Arduino make the LED flash that fast? As a thought exercise, how fast can the LED blink, even if it looks solid?

@underGround, you are still after a short on-pulse followed by variable-length off time, yes? Were you able to get anywhere with things like sbi, cbi, sei ?

@T-Lex, once you get much past 24 blinks/second, (TV refresh speed) I think the eye just perceives the LED as on, with differing brightness levels dependent on the on-time vs the off-time.

AWOL: To be fair, a 16 MHz toggle was not requested. At least, that's how I read it.

WINNER WINNER!!! Chicken Dinner!

Correct, AWOL! I want a 62.5 to 125 nanosecond (or more) Pulse followed by an adjustable off cycle. The whole instruction set could last upwards of a millisecond (.001) or more. I just need that ultra short ON Cycle. And it is NOT for an LED. :P lol

CrossRoads: @underGround, you are still after a short on-pulse followed by variable-length off time, yes? Were you able to get anywhere with things like sbi, cbi, sei ?

fat16lib didn't have anything for me, prolly too busy to educate me just so we could talk on his level. Your PM listed sli & cli didn't it?

Should I lock this topic and post again? Is there anyone out there who would write such a code string for a fee? I'm willing to go that route but the code needs to be User-Adjustable by a noob :astonished: (ME) lol

Is there anyone out there who would write such a code string for a fee? I

If you had no intention of trying yourself, maybe you should've put it in Gigs and Collaborations to begin with

If it were possible to code it in Arduino firmware I'd Gladly give it a go. Machine Language might be too much for the short term. I really need a working, adjustable program for proof of concept. I'll try G&C and see if I get any nibbles THANX ALL!

Ultrashort pulses? Search for "direct port manipulation". This is not hard to pull off.

U know, I should try and do it myself if you folks can help me get started. I want a very simple program like BLINK in Machine Language and have adjustable (through code changes) on and off phases. That is all I need, just a simple code for ON & OFF. Once I prove the concept I can then get elaborate and get an ARM based system and program in my safeties & adjustable outputs, preferably using GUI which is prolly like developing "windows" from the ground up :) :) :) Any idea where I should start??? Still a total noob/newb and I work/drive over 12 hours a day which is the reason I am a bit slow on the R&D phase. Which Machine Language would I learn or is that a stupid Q (is it all the same w/hdwe. variants?) So much to do with so little time

TIA Y'all! undeRGRound

THX UDO!!! looking

Did you see this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1230286016

How exactly timed does the “off” time have to be?

/*
  * pulse PORTB5 (LED) for n machine cycles (62.5ns each)
 * The off time is not particular controlled.
 */
void pulse(int n)
{
  uint8_t on, off;    //values for port reg with LED on and off

    cli();
  off = PORTB;
  on = off | (1<<PORTB5);
  switch(n) {
  case 1:
    asm volatile (
    " out %[port], %[on]\n"
      " out %[port], %[off]\n"
: //output specs (none)
: 
    [port] "I" (_SFR_IO_ADDR(PORTB)),
    [on] "r" (on),
    [off] "r" (off));
    break;
  case 2:
    asm volatile (
    " out %[port], %[on]\n"
      " nop\n"
      " out %[port], %[off]\n"
: //output specs (none)
: 
    [port] "I" (_SFR_IO_ADDR(PORTB)),
    [on] "r" (on),
    [off] "r" (off));
    break;
  case 3:
      asm volatile (
    " out %[port], %[on]\n"
      " nop\n nop\n"
      " out %[port], %[off]\n"
: //output specs (none)
: 
    [port] "I" (_SFR_IO_ADDR(PORTB)),
    [on] "r" (on),
    [off] "r" (off));
    break;
  default:
    // other values are easier.
    // And left as an exercise for the reader.
    break;
  }
  sei();
}

void setup() {
}
void loop() {
  for (int i = 0; i < 100; i++) {
    pulse(i);
  }
}