Skip to content

Instantly share code, notes, and snippets.

@dranger003
Created May 16, 2015 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dranger003/c057bed0708b3aa470b0 to your computer and use it in GitHub Desktop.
Save dranger003/c057bed0708b3aa470b0 to your computer and use it in GitHub Desktop.
// 1 cycle = 62.5ns
int main()
{
DDRD |= _BV(3);
PORTD &= ~_BV(3);
for (;;)
{
PORTD ^= _BV(3); // 5 cycles
if (PORTD & _BV(3)) // 2 cycles
{
__asm__("nop\n\t"); // 1 cycle
_delay_loop_1(44); // 3 cycles per
}
else // 1 cycle
{
_delay_loop_1(91); // 3 cycles per
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment