|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
|
TOP SECRET CodeThe Hard Part So itıs time to write the code for the TSMC. When working with a new micro, the hard part for me always seems to be getting that
first action/reaction of the device. I usually go for something simple like flashing an LED. Itıs kind of like the show "What About
Bob," you need to take baby steps. Click here if you need to review the
hardware it took to get to this point. One final note, as I have said before, donıt expect anything more than snippets of documentation.
I canıt reveal too much lest the purpose of this device be found out.
To begin with, I actually didnıt quite get the hardware complete the last time. I hadnıt hooked up the resistors for my user
input/interface circuit. So I spent the better part of a "burnt finger" hour trying to solder resistors on the tiny control panel.
Here is the back of the board in its entire splendor. In the background you can see my iron, a Radio shack $2.99 special. (Someday
Iım gonnaı get me a real soldering iron with more than two heat settings and a tip smaller than my finger.)
One reason it takes so long is my difficulty with resistor color codes. I do great as long as the value is a multiple of 10, i.e.
1 kW, 10 kW, 100 kW, etc. But send me looking for a
5.1 kW, and you will find me in the lab with a meter picking through a pile of resistors. Sure, you can
use the mnemonic about bad boys, girls, and violetıs promiscuity, but that still involves counting on my fingers. Laziness is the
mother of invention I figure, so I reach for my meter. But I digress.
Finally itıs done. So I install AVR Studio, a programming suite that came with the STK100, which then prompts me to select an
assembler or C compiler when I start a new project. Given the work I want to do and the disk space I have available (just 1K of
program memory), I opt for the assembler. If you have ever debated between assemler and C compiler, take at look at
To C or Not to C, as Robert Ashby so eloquently put it.
Believing in the theory of "fake it till you make it," I immediately lifted some code from some of my coworkers to begin my
project. My sole goal at this point is to flash an LED. When that happens, I will have proven my control over this part, and I
can begin the real work.
Ok, first problem, right after I hook the parallel port from the programmer to the computer, my mouse stops working. "Here we go
again," I thought, "another Microsoft hang up caused by a simple cable swap." Just before rebooting, I noticed that I had knocked
the mouse connector out when I hooked up the cable. Figuring that Iıve had my moment of idiocy on this project
already, only serious problems will be allowed from now on! J
I have two LEDs in my design: the yellow one is hooked to Port B5 and the green is hooked to B0. I have no problem figuring out
where to configure these I/O, but Iıd really like to equate a symbol to each LED, and that has eluded me for a while. (Get up, grab
a soda, and when you come back, it is suddenly clear.) Check out this tantalizing piece of code!
Well, it has been over an hour now, and I still havenıt flashed an LED, I
guess I was rustier than I thought. I continue to plug away at it. I can feel my brain beginning the instruction set assimilation
process (it starts as a dull ache in the back and moves forward to pound the eyeballs). It seems to me like every manufacturer
deems it necessary to come up with their very own mnemonics for the instruction set of their micro. I know, thatıs just
another argument for a C compiler. Maybe, Iıll try to do this project in C using the Atmel C compiler for another article. But
for now, seeing how I donıt remember much of any assembly language, Iıll go ahead and learn this one.
Ok, moment of idiocy number two. I messed around with the simulator for let's say
an undisclosed amount of time. I
couldnıt for the life of me figure out why the interrupt vector wasnıt working right. I then realized that I did not have the
simulator set up for the right type of part. In fact, the version I have doesnıt support the tiny 15. (I guess that happens when
you are on the bleeding edge of technology.) So I go back to the Web site to get AVR Studio version 3.2. A long download
later
Aha! I finally have a flashing LED. Proof that the interrupts are running and the code is executing. Given the time of night
and my raging headache, Iıll practice what I have seen so many programmers do. Take something incomplete, and call it a beta test.
Gotta save something to upgrade!
Tune in next time to talk algorithms.
|
|||||||||||||||||||||||||||||||||||
|
Copyright © 2003 ChipCenter-QuestLink About ChipCenter-Questlink |
||||||||||||||||||||||||||||||||||||