Created
October 31, 2018 17:40
-
-
Save FrankBuss/a214794c530ba62504fd0bbbd48e8c6b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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