8. Embedded programming

Recap Toolchain Button and blinking lights Echo

Recap

The Electronics Production assignment had left an important open issue: I could not program the Fab ISP with my means. Moreover, not being able to get my Fab ISP recognized by my PC would not lead me much far on this new assignment.
I needed to to review in details the information acquired during the electronics lectures and go through all the steps once again. Since I enjoy studying, I got myself some additional material to focus on, notably two very interesting books: “Make: AVR programming” by Elliot Williams and “C All-in-One Desk Reference for Dummies” by Dan Gookin.

Recap AVR structure



Recap the toolchain


Toolchain: resetting the software on my PC (Windows 10)

These are the steps I followed:

  1. Uninstall WinAVR.
  2. Go back to a restore point prior to the previous software installation.
  3. Repeat the Windows Software/Drivers instal. When prompted to change PATH variable during WinAVR installation, so that make, avr-dude and avr-gcc are available without the need to type the full pathname, I confirmed.
  4. Check the solder status of the FabISP and Hello Board (the 6 pin headers had become loose and the LED on the Hello Board had burn out).
  5. Hookup and check pin correspondence (VCC, GND, MOSI, MISO, SCK, RST).
  6. Test AVR connection.
  7. Talk directly to the programmer.
  8. Launch a makefile (I tried with the echo.interrupt program). I run a Make instruction from the same folder where I had placed the C program and the Makefile.

The result was an error: “... died without initialization with status code 0xC0000142”.

I searched the web and found the following solution in the AvrFreaks-Atmel Community:

I replaced the msys-1.0.dll file in the WinAVR-20100110/bin directory.

Hopefully, when I run again the Make instruction, the error had disappeared!

Now that the tool chain is working, I started programming my Hello World board.

In order to program in "C" I found it extremely useful to well understand the following intriguing concepts:

I decided to write a simple program in C that makes the LED blink in two different patterns: when I press the button the first time after powering the board and when I press the button a second time. The cycle then starts all over again. This is the program logical scheme:

Check the toolchain files:

Certainly, there should be more elegant ways to display a repeating instruction like in the sos script. Anyway, at this stage, I kept it as simple as possible. This is the program:

And this is the Makefile

I then run the make instructions in the terminal, from the folder with the .c program and the makefile:

Here is what happened in the program folder:

Make fuse

Make program

Here is the result on the board (click on the picture to see the video):