basic c and make template for atmega328p and usbasp programmer

This commit is contained in:
Timo Volkmann 2020-04-23 17:01:48 +02:00
commit 6248bc8710
5 changed files with 81 additions and 0 deletions

28
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,28 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"usr/local/Cellar/avr-gcc/9.3.0/avr/include/**"
],
"browse": {
"limitSymbolsToIncludedHeaders": true,
"path": [
"${workspaceFolder}/**",
"usr/local/Cellar/avr-gcc/9.3.0/avr/include/**"
]
},
"macFrameworkPath": [],
"compilerPath": "/usr/local/bin/avr-gcc",
"intelliSenseMode": "clang-x64",
"cStandard": "c99",
"cppStandard": "c++11",
"compilerArgs": [
"-mmcu=atmega328p",
""
]
}
],
"version": 4
}

16
Makefile Normal file
View File

@ -0,0 +1,16 @@
MCU=atmega328p
CC=avr-gcc
OBJCOPY=avr-objcopy
CFLAGS=-std=c99 -Wall -g -Os -mmcu=${MCU} -I.
TARGET=blink
SRCS=blink.c
all:
${CC} ${CFLAGS} -o ${TARGET}.bin ${SRCS}
${OBJCOPY} -j .text -j .data -O ihex ${TARGET}.bin ${TARGET}.hex
flash:
avrdude -p ${MCU} -c usbasp -U flash:w:${TARGET}.hex:i -F -P usb
clean:
rm -f *.bin *.hex

BIN
blink.bin Executable file

Binary file not shown.

25
blink.c Normal file
View File

@ -0,0 +1,25 @@
/*
* File: blink.c
* Description: Toggels pin PB0 every 500ms
* From: C-Programmierung mit AVR-GCC
*/
#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRB |= (1 << PB0) | (1 << PB1);
PORTB |= (1 << PB0) | (1 << PB1);
while (1)
{
PORTB ^= (1 << PB0) | (1 << PB1);
_delay_ms(500);
}
return 0;
}

12
blink.hex Normal file
View File

@ -0,0 +1,12 @@
:100000000C9434000C943E000C943E000C943E0082
:100010000C943E000C943E000C943E000C943E0068
:100020000C943E000C943E000C943E000C943E0058
:100030000C943E000C943E000C943E000C943E0048
:100040000C943E000C943E000C943E000C943E0038
:100050000C943E000C943E000C943E000C943E0028
:100060000C943E000C943E0011241FBECFEFD8E04C
:10007000DEBFCDBF0E9440000C9454000C940000E1
:1000800084B1836084B985B1836085B993E085B11B
:10009000892785B92FEF39E688E12150304080402B
:0C00A000E1F700C00000F3CFF894FFCFA0
:00000001FF