Skip to content

Instantly share code, notes, and snippets.

@petrihakkinen
Created November 29, 2014 11:11
Show Gist options
  • Save petrihakkinen/c598f1daa6df8fcfbffb to your computer and use it in GitHub Desktop.
Save petrihakkinen/c598f1daa6df8fcfbffb to your computer and use it in GitHub Desktop.
// stop CPU clock in high state
void stopClock() {
// wait for clock to go low
while((PIND & CPU_CLOCK) != 0) {}
// wait for clock to go high
// must check that WE is high, otherwise CPU may be writing to memory
while((PIND & (CPU_CLOCK|SRAM_WE)) == 0) {}
TCCR2B = 0; // stop timer by setting prescaler to 0
TCCR2A = 0; // disable timer so that we can control PD7 manually
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment