Skip to content

Instantly share code, notes, and snippets.

@FrankBuss
Created October 31, 2018 17:40
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 FrankBuss/a214794c530ba62504fd0bbbd48e8c6b to your computer and use it in GitHub Desktop.
Save FrankBuss/a214794c530ba62504fd0bbbd48e8c6b to your computer and use it in GitHub Desktop.
// set these fuse bits to 0:
// CKDIV8, SUT0, CKSEL3, CKSEL2, and CKSEL0
// the CPU clock is 31250 Hz
#define F_CPU 31250
#include <avr/io.h>
#include <avr/power.h>
#include <util/delay.h>
int main(void)
{
// set pre-scaler of the 8 MHz RC oscillator to 256, for a 31250 Hz clock
clock_prescale_set(clock_div_256);
// all pins as output
DDRB = 0xff;
// 1 Hz blinky
while (1) {
PORTB = 0xff;
_delay_ms(500);
PORTB = 0;
_delay_ms(500);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment