Blinking LEDs

19 Oct, 2009

Project 4: Microprocessing

ECHO-ECHO

The Project:

This project involved adding a button to an existing layout and then programming new code to run on the microprocessor in Assembly and C. Beyond the basic requirements, my target was an 8-bit music player that reads the music sample off of a flash. Unfortunately, while sealing my new room against the cold, I opened up a hole in my wall. So, instead of fun with the TINY 45, I had fun with demolition and drywall. But the whole is patched and even if there is no music playing, there is a blinky LED and there is little I love to do more when microprocessing than making lights blink. Seriously.

Construction Notes:

We were having trouble with the Modella this week. Maybe the sacrificial board is not even or there is some tilt otherwise, but one part of the board mills fine but part of it doesn't have sufficient depth. This was rectified partially by using the opposite corner of the sacrificial board but also required slightly increasing mill depth. Otherwise, construction and soldering were straight-forward as expected. Again, I used a combination of direct solder and solder paste.

programming:

Basic programming of the board went smoothly. I tested my power early and it cleared. The one thing that I have trouble with is that these headers (and cables) are some of the most confusing I've used in terms of where is pin one. For instance, the serial cable is four pin and you can put the cable on in all four directions. Personally, I have physically marked my connectors with pin 1. But the board doesn't easily reveal pin 1 either so this only simplifies, not solves the problem. In the case of the power jack, I actually used a two pin that only fits one direction so I can't mess that up.

Otherwise... not much to say. I'm used to doing embedded programming and have coded significantly in Assembly. First, find the data sheets and come to a basic understanding of both the register sets (for instance, if you are changing a pin from input low to output high you need to transition through an intermediate state) and the instruction set to see what tools you have and how to execute them. Then test your assumptions. Apparently some of mine are wrong asI was having trouble branching as expected based off the LED output pin. For some reason it always branches as if the value is high even when I know it is low. If anything interesting comes out of this misunderstanding, I will add it but it didn't stop me succeeding from the basic goal of toggling an LED. There are other ways to do it not using sbic or sbis.

I went through the assembly and C code and wrote some new code to toggle the LED based on button press. For details on what I did and why, the code is here and commented:

Toggle LED in Assembly

Toggle LED in C