(MC68HC908MR16CFU) and set
the parameters for the PLL. I then
performed a compile and link
(called a make by the IDE)
operation, which generated a Cpu.c
startup source file and a skeleton
nutsvolts.c application source file.
Various other .c and .h support files
were also generated.
At this point, I decided that
everything looked okay. So, I once
again used the Bean Selector and
accessed the Port I/O area of the CPU
Internal Peripherals folder. I double-clicked on the BitIO Bean to add it to
my project. Then, using the Bean
Inspector, I named the newly included BitIO Bean LED_BIT. Since I only
want to make sure I can compile,
link, load, and debug the project
code, I went with the LED_BIT Bean’s
default I/O pin setting of PB2, which
happens to be pin 1 of the
MC68HC908MR16.
In the Methods area of the
LED_BIT Bean, I told the Bean to only
generate code to set and clear the
Port B I/O pin. I then recompiled the
project, which brought in the new
LED_BIT Bean and its associated
code. As you can see in Listing 1
(Listing 1 is available at the Nuts
Volts website; www.nutsvolts.com), I
added my LED blinker code to the
nutsvolts.c application source file,
which uses the LED_BIT LED
BIT_ClrVal and LED_BIT_SetVa
macros and a homebrew for-loop
delay routine. Everything compiled
and linked just fine. I cheerfully
clicked on the CodeWarrior IDE’s
Debug icon.
UH OH
The Cyclone Pro drivers loaded
and the Cyclone Pro contacted and
identified the MC68HC908MR16
MCU that was planted on the solderless breadboard. According to the
various popup messages, the
MC68HC908MR16 erased and
programmed successfully. However,
the program didn’t seem to be
running and the LED was not
blinking. I rechecked my MCU module wiring and traced out all of the
solderless breadboard connections.
I even swapped in a new 4.9152 MHz
crystal.
The stupid thing still would not
run. I was at the point of building
up another MC68HC908MR16 MCU
module. However, I decided to debug
the code to see if everything
was working as designed. From
experience, I know that even the
simplest of LED blinker code can
harbor a nasty eat-you-alive bug.
After single stepping through
the Cpu.c code you see in Listing 2
(Listing 2 is also available at
the Nuts & Volts website.), I noticed
that the program was hanging
while waiting for the PLL to lock.
So, I commented out the whil
(!PBWC_LOCK) statement and its
associated braces and recompiled
the project. The LED blinked as it
should have after reloading the
MC68HC908MR16 with the new code
sans the PBWC_LOCK statement.
&
_
l
e
82
February 2006