From 3fbd0e8b51072ed370fd0cb1f01d4bb85c978652 Mon Sep 17 00:00:00 2001 From: Yuval Adam Date: Sat, 20 Sep 2014 03:32:04 +0300 Subject: Update code to test all LEDs --- Makefile | 2 +- hello.c | 57 ++++++++++++++++++++++++++++++--------------------------- hello.hex | 16 ++++++++++++---- 3 files changed, 43 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index 8df710b..a3d43ac 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ 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-gcc -Wall -Os -DF_CPU=1048576 -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 diff --git a/hello.c b/hello.c index 2d1ba75..e475624 100644 --- a/hello.c +++ b/hello.c @@ -1,32 +1,35 @@ + #include -// F_CPU frequency to be defined at command line #include -// LED is on pin 2, PB3 -#define LED PB3 -#define DELAY_MS 500 - -int main () { - uint8_t high = 0; - uint16_t ms = 0; - - DDRB |= (1 << LED); - PORTB &= ~(1 << LED); - - while (1) { - high = !high; - - if (high) { - PORTB |= (1 << LED); - } else { - PORTB &= ~(1 << LED); - } - - for (ms = DELAY_MS; ms > 0; ms -= 10) { - _delay_ms(10); - } - } - - return 0; +int +main (void) +{ + DDRB |= _BV(DDB0); + DDRB |= _BV(DDB1); + DDRB |= _BV(DDB2); + DDRB |= _BV(DDB3); + DDRB |= _BV(DDB4); + while(1) { + PORTB ^= _BV(PB0); + _delay_ms(500); + PORTB ^= _BV(PB0); + + PORTB ^= _BV(PB1); + _delay_ms(500); + PORTB ^= _BV(PB1); + + PORTB ^= _BV(PB2); + _delay_ms(500); + PORTB ^= _BV(PB2); + + PORTB ^= _BV(PB3); + _delay_ms(500); + PORTB ^= _BV(PB3); + + PORTB ^= _BV(PB4); + _delay_ms(500); + PORTB ^= _BV(PB4); + } } diff --git a/hello.hex b/hello.hex index 9f6b12f..c30d990 100644 --- a/hello.hex +++ b/hello.hex @@ -1,7 +1,15 @@ :100000000EC015C014C013C012C011C010C00FC064 :100010000EC00DC00CC00BC00AC009C008C011241E -:100020001FBECFE5D2E0DEBFCDBF02D016C0E8CF05 -:10003000BB9AC39880E091E0892711F0C39A01C070 -:10004000C39822E330E0E3ECF9E03197F1F700C028 -:0E005000000021503109B9F7EFCFF894FFCF2F +:100020001FBECFE5D2E0DEBFCDBF02D052C0E8CFC9 +:10003000B89AB99ABA9ABB9ABC9A51E042E034E0B5 +:1000400028E090E188B3852788BB69E979E981E0F8 +:10005000615070408040E1F7000088B3852788BB7D +:1000600088B3842788BB69E979E981E061507040F1 +:100070008040E1F7000088B3842788BB88B38327DA +:1000800088BB69E979E981E0615070408040E1F71F +:10009000000088B3832788BB88B3822788BB69E9BF +:1000A00079E981E0615070408040E1F7000088B359 +:1000B000822788BB88B3892788BB69E979E981E011 +:1000C000615070408040E1F7000088B3892788BB09 +:0600D000B9CFF894FFCF48 :00000001FF -- cgit v1.3.1