1.8 Embedded programming
The assigment:
Read a microcontroller datasheet and program it in several languages.
Hello Microcontroller / Atmel AVR ATtiny44A datasheet
A microcontroller is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. It is different from a microprocessor in that a microcontroller includes a CPU, a fixed amount of RAM, ROM and other peripherals all embedded on a single chip.
I am using the Atmel AVR ATtiny44A in the Electronics Design assignment and its datasheet is on this document (.pdf). There is a curious think about the real meaning of the AVR acronym, read on Wikipedia
![](http://farm3.staticflickr.com/2879/9333619891_2c2ba3a17a_n.jpg)
There is a guide of the pins from the High-Low Tech Group at the Media Lab:
![](http://hlt.media.mit.edu/wp-content/uploads/2011/10/ATtiny44-84.png)
I also found really interesting this guide because explains in a simple way how microcontrollers work Beginning Embedded Electronics - 1 / Lecture 1 - Background and Power Supply
Ingredients
Physical stuff (Atoms)
Digital stuff (Bits)
Instructions to program in C using GNU Make and avrdude
Steps
It is necesary to conect all the components as indicated on the diagram.
![](http://farm3.staticflickr.com/2846/9335834385_8af70d2049.jpg)
Run the following command on the terminal: sudo make -f hello.ftdi.44.echo.c.make program-usbtiny-fuses
![](http://farm6.staticflickr.com/5544/9448774472_551a2a4373_n.jpg)
Observation: In case you are using the AVR ISP mkII, then the command is sudo make -f hello.ftdi.44.echo.c.make program-avrisp2-fuses
There is an error on the line 216 of the C source code, it must be added the const as on the image.
![](http://farm6.staticflickr.com/5514/9445987745_08169af054.jpg)
The program will respond with a Fuses OK. Thats the signal that everything went fine. If not, check your board first.
![](http://farm4.staticflickr.com/3743/9445987869_64b92bb1aa_n.jpg)
sudo make -f hello.ftdi.44.echo.c.make program-usbtiny if you are using the FabISP
sudo make -f hello.ftdi.44.echo.c.make program-avrisp2 if you are using the AVR ISP mkII
![](http://farm6.staticflickr.com/5526/9448774388_fae57d22c9_n.jpg)
![](http://farm4.staticflickr.com/3828/9448774326_bafeefea99_n.jpg)
![](http://farm4.staticflickr.com/3687/9445987785_c21af3e0a8_n.jpg)
Instructions to program the microcontroller with the Arduino IDE
Steps
It is necesary to conect all the components as indicated on the diagram.
![](http://farm3.staticflickr.com/2846/9335834385_8af70d2049.jpg)
Inside your sketchbook folder create a new one called hardware and decompress all the content of the master.zip file:
![](http://farm6.staticflickr.com/5548/9446593037_f205e9f368_n.jpg)
Tools-->Board-->ATtiny44 (external 20Mhz)
![](http://farm4.staticflickr.com/3762/9446593081_c66985b281_n.jpg)
Tools-->Serial Port-->/dev/ttyUSB0 (Depends on your operating system, on GNU/Linux use ls /dev/tty* to discover your port list and select accordingly)
![](http://farm3.staticflickr.com/2844/9446593099_bf80d5a532_n.jpg)
Tools-->Programmer-->AVRISP mkII (depends on the ISP used)
![](http://farm8.staticflickr.com/7349/9449376546_47d2ed058f_n.jpg)
![](http://farm4.staticflickr.com/3813/9449376578_16e73f254e_n.jpg)
In GNU/Linux, after you try to upload the code to the microcontroller sometimes is required some aditional activities.
First create a rule inside /etc/udev/rules.d/, it can be named: 10-usbtinyisp.rules and is necesary to add this line only: SUBSYSTEM=="usb", ATTR{product}=="USBtiny", ATTR{idProduct}=="0c9f", ATTRS{idVendor}=="1781", MODE="0660", GROUP="dialout"
![](http://farm8.staticflickr.com/7337/9449376676_e128e6c3ca_n.jpg)
After that, execute the following command on the terminal: sudo udevadm trigger (this forum provides more related information)
The message area from the Arduino IDE will display: Done uploading.
![](http://farm8.staticflickr.com/7381/9446593217_86b1506ff4_n.jpg)
![Done uploading message](http://farm4.staticflickr.com/3815/9446593227_4931465b13.jpg)
Because of the code loaded, every time the button is pushed, the LED will change it state from ON to OFF and viceversa.
![LED Off](http://farm6.staticflickr.com/5547/9447061639_19349d9f8b_n.jpg)
![LED On](http://farm4.staticflickr.com/3731/9447061593_10e83eb9ae_n.jpg)
Results:
The board previously designed was programmed. The microcontroller now has a code inside that makes that every input read over the serial port will be returned to the computer using the same port.