Homework 1
This assignment should be handed in before class on Thursday Feb 19,
2009. Handin is on the CADE lab machines using commands like this:
handin regehr hw1 filename
Where "filename" is the name of a file to hand in. The exact names you
should use are given below.
You'll need to install version 4.7 of the "special edition" of
CodeWarrior for HCS12(X), which is available from the FreeScale web
site. Of course you can just use a lab machine where this is already
installed.
We'll discuss this homework in class on 2/10.
-
In class we discussed how the Timer_Wait function from slide 15 of
Lecture 4 is broken. Write a correct version and hand in a file
containing the code as prob1.c. Include any necessary header files.
The file should be compilable using CodeWarrior for HCS12 in a project
for our chip (to create such a project see the Lab 1 writeup). Also
handin a compiled, disassembled version of your function as
prob1.asm.
-
Create a new code warrior project for your chip. Next, by pressing
Alt-F7 in CodeWarrior and then moving to "compiler for hc12", tell the
compiler to optimize for maximal code density (look under "smart
sliders"). Type in the "Mealy FSM" from Lecture 4. Compile it and
(using the manuals) figure out how many cycles it will take to execute
the main loop, in the worst case. In other words, pick an instruction
in the main loop and figure out how long in cycles -- at most -- it
will take the CPU to reach this point again. Timing information is
available in your manuals. Handin a dissasembled version of the
application where instructions in the main loop are labeled with their
cycle counts. Call this file prob2.asm.
-
Repeat the exercise from problem 2, but this time reimplement the
Mealy FSM without using function pointers (how you do this is up to
you). Call the file you handin prob3.asm. The effect
of the FSM should be exactly the same as the version from lecture.