Embedded Programming
The Assignment...
- Read a microcontroller data sheet
- Program your board to do something, with as many different programming languages and programming environments as possible
- Data Sheets
- Pin Configurations
- Pin descriptions
- Registers
- Packaging Information
- Device Programming
- using Arduino IDE on Linux and on Windows
- using AVRDUDE command line utility on Linux and on Windows
- using Atmel Studio on Windows
- using WinAVR Tools on Windows
- Arduino IDE
- Windows
- Linux
- Atmel Studio
- WINAVR
- Source file (Main file name)
- Microcontroller (MCU Type which in my case was the ATtiny44A)
- Programmer (I was using the fabisp so my programmer was usbtiny)
- Programming port (usb)
- AVRDUDE
- Windows
- Linux
For the first part of the assignment, I went through the datasheets for the ATtiny44A since I used it for my fabisp and ledbutton designs and the ATmega328P as I like it and use it a lot e.g FabISP Demo video, week04.




Of note in the datasheets with was;
For the second part of the assignment, I programmed the helloworld board with 'blink LED' code;
First up was using Arduino IDE on Windows. Before I could upload code to the board I had to go through some preliminaries first and so I followed the tutorial here.
Finally...

I then edited the blink LED example code to suit my circuit as per this configuration;

In my case, the LED was connected to pin PA3 which, as per the configuration above, is Pin 3. The alternative was to use the AVR pin identifier which in this case was PA3 which was the option I used in this case.
Edited Blink LED code...

As I was using my FABIsp to load the code, I first selected the board as "ATtiny24/44/84" and the programmer as USBTiny.


I then went ahead and programmed the board using the 'Upload Using Programmer' option.

At this point the program upload failed with the error:
Wrong microcontroller found. Did you select the right board from the Tools > Board menu?
So I checked the board menu and realized that the selected processor was ATtiny24. I therefore corrected the error.

Re-Uploading the code... Success!

I prepared the IDE the same way as I did on Windows.The procedure for uploading the code was similar to what I had done on Windows, with the exception of the pin configuration. In this case I Used Pin 3 to define the LED Pin.
I started with the example Blink LED code.

Changed the Pin definitions...


I then uploaded the code, again using the 'Upload Using Programmer' option. This was a success.



For this section I used Atmel Studio 7 which was what I had installed. Unfortunately, Atmel Studio which is the official development software from Atmel, only supports STK500 and AVRISP programmers which are the official programmers
Of note is that Atmel Studio 7, which is the latest Atmel Studio, supports AVRDUDE and so the following only applies to Atmel Studio 7. For older versions of Atmel Studio, using USBTiny will require the following tutorial.
For Atmel Studio 7, I followed the tutorial here
In summary, I had to configure Atmel Studio to use AVRDUDE by defining an 'External Tool'
First I created a new tool. It should be noted that I had already configured an external tool for programming the ATMega328p using USBTiny and as such had WINAVR already installed. In order to program the ATtiny44 on my board I first had to change the name of the already configured external tool.



Selecting the External Tools option...

Selecting the already existing tool...

Renaming the tool to USBTiny ATmega328p...

Renamed and saved tool...

Creating the new tool for the ATtiny44...




3

At this point I proceeded to open a new project for Blink LED code...




I then created a new C/C++ source file for the code and wrote the code.

I then proceeded to build the code...


Uploading the code was as simple as selecting the tool that I had created from the tools menu.




I had WINAVR installed but I had not used it yet. So, I opened a copy of the Blink LED code I had written in Atmel Studio with Programmer's Notepad one of the tools that comes bundled with WINAVR. I then opened MFile, the Makefile generation tool...


I then edited the Makefile. This is done using the 'Makefile' drop-down menu. Changes to be made included:
Changing source file name...




Changing micro-controller...




Changing programmer...

Unfortunately the usbtiny was not listed in the programmer list and so had to be manually changed. This was done by first enabling manual editing by selecting the 'Enable Editing of Makefile' option...

I then manually changed the programmer from stk500v2 to usbtiny.


Changing the programmer port...

Once done, I saved the Makefile in the same folder as the blink.c file...


I then switched to programmer's notepad...

I then ran Make Clean followed by Make All from the tools menu...


At this point Make All exited with an error (highlighted)

I ran 'make' on terminal (Windows PowerShell) in order to confirm that the error was not application specific and got the same error. After some research online, I found a solution that involved downloading a .dll (msys-1.0.dll) from here and copying it to your WINAVR utils\bin directory.
I again ran Make Clean followed by Make All and was successful.


I then ran Program to program the board...


I had now successfully programmed the board with WINAVR.
Running AVRDUDE on Windows required installing WINAVR, which I had installed and used and using the Windows terminal (Powershell). I launched Powershell and navigated to the directory from which I had previously run Programmer's Notepad. I did not need to generate the required .hex file as it had already been generated while using Programmer's Notepad
I than ran the command...
avrdude -p t44 -c usbtiny -p usb
This was to ensure that my computer has access to both the programmer and the micro-controller.
To upload the hex file, I ran the command...
avrdude -p t44 -c usbtiny -p usb -U flash:w:blink.c.hex:i

Running AVRDUDE on Linux was not much different from Windows. I simply ran the commands...
make clean
This removed left-over files from a previous build, followed by
make
to generate the relevant .hex file...

To upload the hex file, I ran the command...
avrdude -p t44 -c usbtiny -P usb -U flash:w:blink.c.hex:i

Assignment wise:
- Read a microcontroller data sheet
- Program your board to do something, with as many different programming languages and programming environments as possible