Skip to content
Snippets Groups Projects
Commit 4951f144 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Beispielprogramme für Mikrocontrollerprogrammierung

parent 7b425c46
Branches
No related tags found
No related merge requests found
%.elf: %.c
avr-gcc -Wall -Os -c -mmcu=atmega328p $< -o $@
%.hex: %.elf
avr-objcopy -O ihex $< $@
upload:
avrdude -P /dev/ttyACM0 -c arduino -p m16 \
-U flash:w:$(ls -rt *.hex | tail -1)
#include <avr/io.h>
int main (void)
{
DDRD = 0x0f; /* binär: 0000 1111 */
PORTD = 0x01; /* binär: 0000 0001 */
while (1);
return 0;
}
#include <avr/io.h>
#define F_CPU 16000000l
#include <util/delay.h>
int main (void)
{
DDRD = 0x0f;
PORTD = 0x01;
while (1)
{
_delay_ms (500);
PORTD &= ~0x01;
_delay_ms (500);
PORTD |= 0x01;
}
return 0;
}
#include <avr/io.h>
#define F_CPU 16000000l
#include <util/delay.h>
int main (void)
{
DDRD = 0x0f;
PORTD = 0x01;
while (1)
{
_delay_ms (500);
PORTD ^= 0x01;
}
return 0;
}
#include <avr/io.h>
#define F_CPU 16000000
#include <util/delay.h>
int main (void)
{
DDRD = 0x01;
PORTD = 0x01;
while (1)
{
while ((PIND & 0x02) == 0)
; /* just wait */
PORTD ^= 0x01;
}
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment