diff options
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | Makefile | 9 | ||||
| -rw-r--r-- | README.md | 36 | ||||
| -rw-r--r-- | hello.c | 48 |
4 files changed, 96 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01927f8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.hex +*.o +*.swp diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8df710b --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ + +default: + # compile for attiny86 with warnings, optimizations, and 1 MHz clock frequency + avr-gcc -Wall -Os -DF_CPU=1000000 -mmcu=attiny85 -o hello.o hello.c + avr-objcopy -j .text -j .data -O ihex hello.o hello.hex + avrdude -c usbasp -p t85 -U flash:w:hello.hex:i + +clean: /dev/null + rm -f hello.o hello.hex diff --git a/README.md b/README.md new file mode 100644 index 0000000..4fae5e4 --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# ATtiny85 Blink + +Runs on the Tel Aviv Makers ATtami board. + +## Prerequisites + + - AVR GCC + - ATMEL USB ISP (USBASP) programmer + +Recommended to use the following udev rule: + +```bash +$ cat /etc/udev/rules.d/98-usbasp.rules +SUBSYSTEM=="usb", ATTRS{idVendor}=="16c0", ATTRS{idProduct}=="05dc", GROUP="users", MODE="0666" +``` + +## Usage + +Connect the following pins: + + - Vcc + - Ground + - PB0 -- MOSI + - PB1 -- MISO + - PB2 -- SCK + - PB5 -- RST + +Then, run: + +```bash +$ make +``` +## Credits + +Based on work done by https://github.com/casebeer/attiny85-hello-world + @@ -0,0 +1,48 @@ + +/** + * + * Blinking LED ATTiny85 "hello world" + * + * Following the tutorial at: + * http://www.instructables.com/id/Honey-I-Shrunk-the-Arduino-Moving-from-Arduino-t/?ALLSTEPS + * + */ + +#include <avr/io.h> +// F_CPU frequency to be defined at command line +#include <util/delay.h> + +// LED is on pin 2, PB3 +#define LED PB3 +#define DELAY_MS 500 + +int main () { + uint8_t high = 0; + uint16_t ms = 0; + + // setup LED pin for output in port B's direction register + DDRB |= (1 << LED); + + // set LED pin LOW + PORTB &= ~(1 << LED); + + while (1) { + high = !high; + + if (high) { + // set LED pin HIGH + PORTB |= (1 << LED); + } else { + // set LED pin LOW + PORTB &= ~(1 << LED); + } + + // delay for 500 ms + for (ms = DELAY_MS; ms > 0; ms -= 10) { + _delay_ms(10); + } + } + + return 0; +} + |
