From 110e71c2334950b0fcdd2f90bff595f55390666d Mon Sep 17 00:00:00 2001 From: Charles Lohr Date: Mon, 5 Dec 2016 21:27:57 -0500 Subject: Update with changes from livestream. --- tools/avr_codegen/Makefile | 3 ++- tools/avr_codegen/test.c | 57 ++++++++++++++++++++------------------------- tools/avr_codegen/test.elf | Bin 6744 -> 6792 bytes tools/avr_codegen/test.hex | 8 ++++--- 4 files changed, 32 insertions(+), 36 deletions(-) (limited to 'tools') diff --git a/tools/avr_codegen/Makefile b/tools/avr_codegen/Makefile index fc2c712..e7b8673 100644 --- a/tools/avr_codegen/Makefile +++ b/tools/avr_codegen/Makefile @@ -1,5 +1,5 @@ -all : test.hex burn test.lst +all : test.hex test.lst PART=attiny85 PROGPART=t85 @@ -10,6 +10,7 @@ CC=avr-gcc test.hex : test.elf avr-objcopy -j .text -j .data -O ihex test.elf test.hex + avrdude -c usbtiny -p $(PROGPART) -V -U flash:w:test.hex test.elf : test.c avr-gcc -I -g $(CFLAGS) -mmcu=$(PART) -Wl,-Map,test.map -o $@ test.c -L/usr/lib/binutils/avr/2.18 diff --git a/tools/avr_codegen/test.c b/tools/avr_codegen/test.c index 24b9066..2c875f1 100644 --- a/tools/avr_codegen/test.c +++ b/tools/avr_codegen/test.c @@ -26,6 +26,7 @@ static void setup_clock( void ) int main( ) { + int k; cli(); setup_clock(); DDRB = _BV(4) | _BV(3) | _BV(1); @@ -50,38 +51,30 @@ int main( ) // 14 = 0x95 0x01 // 15 = 0xa1 0x01 //0x10 = 0xab 0x01 - marker = 30; - do{ - PORTB = _BV(3); //4 = 0x40 3 = 0x48 1 = 0x50 - marker--; - PORTB = 0; - } while( marker ); - marker = 30; -/* do{ - PORTB = _BV(3)|_BV(1); //4 = 0x40 3 = 0x48 1 = 0x50 - marker--; - PORTB = 0; - } while( marker ); - marker = 30; - do{ - PORTB = _BV(3); //4 = 0x40 3 = 0x48 1 = 0x50 - marker--; - PORTB = 0; - } while( marker ); - marker = 30; - do{ - PORTB = _BV(3)|_BV(4); //4 = 0x40 3 = 0x48 1 = 0x50 - marker--; - PORTB = 0; - } while( marker ); - marker = 30; - do{ - PORTB = _BV(3); //4 = 0x40 3 = 0x48 1 = 0x50 - marker--; - PORTB = 0; - } while( marker ); - _delay_us(80); -*/ + + // 0x81 0x04 + // <- <- + + // First look at 0x04. There will be another byte because it is less than + // 128! + // 0x04<<7 = 0x200 + // Because 0x81 is >= 128, it's a terminator. + // 0x200 | 0x81 = 0x281 << The actual value + // + + // _BV(x) is a synonym for (1<