Week 7. Programming week. So my board is programmed with the Hello echo program and it answers to terminal. Its time to do some programming on my own and test the button and the LED. First I used Gedit in Linux to write a simple program to set the LED when the button is pressed and switch it off if the button is released. I compiled C-code and programmed it into the development board directly from command line since AVR-GCC and AVRDDUDE had already been installed. I used these commands to make an elf file from the C, make a hex file from the elf and program the board. "button" is the name of the file.
When it comes to reading the microcontroller's datasheet, there is no new information for me. It's good to refresh the memory though.
- avr-gcc -mmcu=attiny44a -Wall -Os -o button.elf button.c
- avr-objcopy -j .text -j .data -O ihex button.elf button.hex
- sudo avrdude -p t44 -P usb -c usbtiny -U flash:w:button.hex
We have light! Below are the programming setting and the working device.
According to Wiki there is a huge punch of programming languages to AVR family:
- AVR Assembly Language
- Ada
- B#
- BASIC
- C
- C++
- Java
- JavaScript
- Pascal
- Forth
- Python
- Scheme
Of which C is the "De facto standard" in industry, most C environments also understand C++, assembly is used when code must be optimized clock cycle by clock cycle and python is very neat high level language. I wasn't able to find complete python implementations for modern python versions and AVR family.
Arduino IDE can also be used to program ATtiny44. I used the same program as with AVR-GCC, I just put the codes in right places in Arduino IDE for setup and eternal loop. For Arduino, you need to:
- Install Arduino IDE
- Install Libraryes for tiny from: http://highlowtech.org/?p=1695
- Install drivers if using windows for programmer from: https://learn.adafruit.com/usbtinyisp/drivers
Assebly can also be mixed with C. The technique is called the "inline assembly". I used Atmel Studio 6.2 with the same program as earlier except for a couple of lines assembly in the code. Last weeks task of simulating the circuit didn't work out, so last week I only simulated my own amplifier circuit with LT-Spice. This week I simulated and debugged the ATtiny44 in the Atmel Studio. Last I programmed the HEX file in with AVRDUDE since FabISP is not recognized by Atmel Studio.