Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tobias Theobald
TinyMega-HelloWorld
Commits
6028f1c3
Commit
6028f1c3
authored
Oct 01, 2015
by
Tobias Theobald
Browse files
Initial commit
parents
Changes
4
Show whitespace changes
Inline
Side-by-side
.gitignore
0 → 100644
View file @
6028f1c3
*.hex
*.o
Makefile
0 → 100644
View file @
6028f1c3
AVR_CHIP
=
atmega32u4
AVR_CHIP_FREQUENCY
=
16000000
CODE_MAIN
=
helloworld
AVR_PROGRAMMER
=
dfu-programmer
AVR_COMPILER
=
avr-gcc
AVR_HEX
=
avr-objcopy
all
:
$(CODE_MAIN).hex
%.o
:
%.c
$(AVR_COMPILER)
-DF_CPU
=
$(AVR_CHIP_FREQUENCY)
-Os
-mmcu
=
$(AVR_CHIP)
-o
$@
$<
%.hex
:
%.o
$(AVR_HEX)
-O
ihex
$<
$@
.phony flash
:
$(CODE_MAIN).hex
sudo
$(AVR_PROGRAMMER)
$(AVR_CHIP)
erase
sudo
$(AVR_PROGRAMMER)
$(AVR_CHIP)
flash
$<
sudo
$(AVR_PROGRAMMER)
$(AVR_CHIP)
start
;
true
README
0 → 100644
View file @
6028f1c3
benötigte Pakete: avr-gcc avr-binutils avr-libc dfu-programmer.
Wenn es erfolgreich angeschlossen ist liefert
$ lsusb
einen "Atmel Corp. atmega32u4 DFU bootloader". Dann kann mit
$ make
$ make flash
das Programm gebaut und geflasht werden.
Achtung: Zum ersten flashen muss manuell der folgende Befehl ausgeführt werden:
$ sudo dfu-programmer atmega32u4 erase --force
dann funktioniert make flash erst.
helloworld.c
0 → 100644
View file @
6028f1c3
#include <avr/io.h>
#include <util/delay.h>
#include <avr/power.h>
#include <avr/interrupt.h>
int
main
()
{
// internen clock teiler deaktivieren
clock_prescale_set
(
clock_div_1
);
sei
();
// set interrupts
DDRE
|=
(
1
<<
PE6
);
// pin 6 von port E als output schalten
while
(
1
)
{
// endlosschleife fürs blinken
PORTE
|=
(
1
<<
PE6
);
// pin 6 von port E auf high schalten
_delay_ms
(
150
);
// warte 150ms
PORTE
&=
~
(
1
<<
PE6
);
// pin 6 von port E auf low schalten
_delay_ms
(
150
);
// warte 150ms
}
return
0
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment