Introduction and Overview
This laboratory experiment is an exercise of assembly code design and debugging using
CodeWarrior IDE (Integrated Development Environment). Using basic coding
commands in Assembly I am going to drive LEDs on the Dragon12-Plus-USB
development board. These LED’s will turn on and off to present flashing LEDs.

Equipment and Parts
This lab uses the Dragon12-Plus-USB development board. CodeWarrior IDE is fully
capable of talking to the Dragon board via USB using the serial monitor. In previous labs
we used full chip simulation, this is changed by clicking on the serial monitor option
during the setup. The Freescale HCS12D Family Microcontroller was specified in the
software, specifically MC9S12DG256B.
Theory
I am going to have to start the code by telling my stack pointer where to start. I also want
to define my output and input ports. Previously when I defined my ports I would do
something like “a : OUTPUT”. This is of course AHDL, in assembly I define my ports
by either storing all 1’s or all 0’s in that port. I am going to make DDRB & DDRJ output
ports, and therefore will store all 1’s or #$FF to the ports. I will make the PTJ port my
input port, and therefore store all 0’s or #$00 to that port.
I will then define my variables such as R1, R2, and R3. Next I will compose my loop
code. I define my ports differently when writing data to them, such as turning on and off
the LEDs. When writing data to port B, for example, instead of calling it DDRB as I did
when defining my output, I call it PORTB. Refer to ‘derivative.inc’ source file for
variable names.
Direction Data
DDRB PORTB
DDRJ PTJ
The delay portion of the code is needed, because without it I wouldn’t be able to see the
LEDs flashing, the code would be looping too fast for our eyes to see. All the delay
portion of the code does is take up time, and in assembly we take up time by writing
instructions to keep the microcontroller busy. The instructions don’t accomplish
anything useful, they just take up time. Many instructions take up time, such as storing
and loading data continuously.
Schematic Diagram of The Circuits

I have eliminated even more of the main framework code from last lab. I want to focus
only on the needed portion of the code.
Results

(click→debug)

7 SEG jumper removed for
smooth operation
It is clearly visible that one set of LEDs are blinking in the left picture, then the next set
of LEDs are blinking in the right picture. I of course slowed the Delay time down to 100
to make it easier to take the pictures. I also needed to remove the “jumper” out for the 7
segment display, because it was interfering with my operation.
Connecting the USB can be confusing. Once the USB has been connected I need to
check what port it is on.
Control Panel→System→Device Manager→ports (COM)
After finding out what com port is being used I then tell CodeWarrior what com port to
use.

Conclusion
I have used some basic assembly commands to flash the LEDs. I only used the code
needed to avoid any unnecessary confusion. I have also displayed my capability to debug
my code and display the proper output via USB serial monitor. Using the code
framework provided by CodeWarrior and the information in Huang’s book I was able to
successfully complete the lab.

Led flash

  • 1.
    Introduction and Overview Thislaboratory experiment is an exercise of assembly code design and debugging using CodeWarrior IDE (Integrated Development Environment). Using basic coding commands in Assembly I am going to drive LEDs on the Dragon12-Plus-USB development board. These LED’s will turn on and off to present flashing LEDs. Equipment and Parts This lab uses the Dragon12-Plus-USB development board. CodeWarrior IDE is fully capable of talking to the Dragon board via USB using the serial monitor. In previous labs we used full chip simulation, this is changed by clicking on the serial monitor option during the setup. The Freescale HCS12D Family Microcontroller was specified in the software, specifically MC9S12DG256B. Theory I am going to have to start the code by telling my stack pointer where to start. I also want to define my output and input ports. Previously when I defined my ports I would do something like “a : OUTPUT”. This is of course AHDL, in assembly I define my ports by either storing all 1’s or all 0’s in that port. I am going to make DDRB & DDRJ output ports, and therefore will store all 1’s or #$FF to the ports. I will make the PTJ port my input port, and therefore store all 0’s or #$00 to that port. I will then define my variables such as R1, R2, and R3. Next I will compose my loop code. I define my ports differently when writing data to them, such as turning on and off the LEDs. When writing data to port B, for example, instead of calling it DDRB as I did when defining my output, I call it PORTB. Refer to ‘derivative.inc’ source file for variable names. Direction Data DDRB PORTB DDRJ PTJ The delay portion of the code is needed, because without it I wouldn’t be able to see the LEDs flashing, the code would be looping too fast for our eyes to see. All the delay portion of the code does is take up time, and in assembly we take up time by writing instructions to keep the microcontroller busy. The instructions don’t accomplish anything useful, they just take up time. Many instructions take up time, such as storing and loading data continuously.
  • 2.
    Schematic Diagram ofThe Circuits I have eliminated even more of the main framework code from last lab. I want to focus only on the needed portion of the code.
  • 3.
    Results (click→debug) 7 SEG jumperremoved for smooth operation It is clearly visible that one set of LEDs are blinking in the left picture, then the next set of LEDs are blinking in the right picture. I of course slowed the Delay time down to 100 to make it easier to take the pictures. I also needed to remove the “jumper” out for the 7 segment display, because it was interfering with my operation. Connecting the USB can be confusing. Once the USB has been connected I need to check what port it is on. Control Panel→System→Device Manager→ports (COM) After finding out what com port is being used I then tell CodeWarrior what com port to use. Conclusion I have used some basic assembly commands to flash the LEDs. I only used the code needed to avoid any unnecessary confusion. I have also displayed my capability to debug my code and display the proper output via USB serial monitor. Using the code framework provided by CodeWarrior and the information in Huang’s book I was able to successfully complete the lab.