SlideShare a Scribd company logo
1 of 6
Download to read offline
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 the 7 segment display on the Dragon12-PlusUSB development board. The 7 Segment display will present my birth year and name
separately, since there are only four 7 segments displays.

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 & DDRP
output ports, and therefore will store all 1’s or #$FF to the ports.
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
DDRP PTP

PORTB is where I tell it what data I want displayed
PTP is used to tell the Dragon Board which 7 SEG to use

The delay portion of the code is needed, because without it I wouldn’t be able to see the
numbers, 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.
In this particular lab I had almost no delay, because I wanted the code to cycle so fast it
would appear that all the numbers are on at the “same time”.
Design Calculations
Binary to Hex conversion
a

00110111
8 4 2 1 8 4 2 1

b

f

a

a

g

$

a

e

3

7

= $37

c
dp

a
a

d

a

a

#

dp

g

f

e

d

c

b

a

hex

1

0

0

0

0

0

1

1

0

$06

9

1

1

1

0

0

1

1

1

$E7

8

1

1

1

1

1

1

1

1

$FF

8

0

1

1

1

1

1

1

1

$7F

#

dp

g

f

e

d

c

b

a

hex

n

0

0

1

1

0

1

1

1

$37

I

0

0

0

0

0

1

1

0

$06

K

0

1

1

1

0

1

1

0

$76

E

0

1

1

1

1

0

0

1

$79
Schematic Diagram of The Circuits

Displaying my birthday on the 7 segment display
Displaying my name, or one similar to it on the 7 segment display

Notice I had to speed up the delay time so that there was almost no delay. This was
needed to display all the 7 segments at the “same time”.
Results

(click→debug)

It is clearly visible that the left picture displays 1988 and the right displays nIKE, of
course I included the dots to show I am capable of using them. If our eyes could see what
the code was actually presenting it would show:
8 is displayed then turned off
8 is displayed then turned off
9 is displayed then turned off
1 is displayed then turned off
repeat
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.

Problems Encountered
This lab was particularly confusing, because it used 2 output ports. I had a hard time
wrapping my head around which port does what. I now understand and clearly explained
it in the theory section. This is because I am used to programming using Arduino, which
I would define the pins as an output in the beginning, but I can also write data to that
same pin (ie. Pin 1).
I also wanted to actually display all four 7 segments at the same time. I am not able to do
this, because I keep rewriting to PTP, which erases the data from the last instruction. In
order to accomplish turning all the 7 segment displays at the same time each display
would need its own port.
Conclusion
I have used some basic assembly commands to utilize the 7 segment displays. 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.

More Related Content

What's hot

Branch instructions in 8051 micrcocontroller
Branch instructions in 8051 micrcocontrollerBranch instructions in 8051 micrcocontroller
Branch instructions in 8051 micrcocontrollerUshaRani289
 
Digital design (3rd ed) morris mano
Digital design (3rd ed) morris manoDigital design (3rd ed) morris mano
Digital design (3rd ed) morris manoDarling Siva
 
Applications of fourier series in electrical engineering
Applications of fourier series in electrical engineering Applications of fourier series in electrical engineering
Applications of fourier series in electrical engineering Engr Mir Noor Ahmed Langove
 
Project Report On 0-9 decade counter
Project Report On 0-9 decade counterProject Report On 0-9 decade counter
Project Report On 0-9 decade counterOmkar Rane
 
Magnitude comparator
Magnitude comparatorMagnitude comparator
Magnitude comparatorSyed Saeed
 
Interrupts programming in embedded C using 8051
Interrupts programming in embedded C using 8051Interrupts programming in embedded C using 8051
Interrupts programming in embedded C using 8051Vikas Dongre
 
Fast Fourier Transform
Fast Fourier TransformFast Fourier Transform
Fast Fourier Transformop205
 
Digital Electronics - Counters
Digital Electronics - CountersDigital Electronics - Counters
Digital Electronics - CountersJayakrishnanJ11
 
TRAFFIC LIGHT CONTROL SYSTEM USING 8085 MICROPROCESSOR
TRAFFIC LIGHT CONTROL SYSTEM USING 8085 MICROPROCESSORTRAFFIC LIGHT CONTROL SYSTEM USING 8085 MICROPROCESSOR
TRAFFIC LIGHT CONTROL SYSTEM USING 8085 MICROPROCESSORSubash Sambath Kumar
 
Design of Elevator Controller using Verilog HDL
Design of Elevator Controller using Verilog HDLDesign of Elevator Controller using Verilog HDL
Design of Elevator Controller using Verilog HDLVishesh Thakur
 
Addition and subtraction with signed magnitude data (mano
Addition and subtraction with signed magnitude data (manoAddition and subtraction with signed magnitude data (mano
Addition and subtraction with signed magnitude data (manocs19club
 
7-Segment Display
7-Segment Display7-Segment Display
7-Segment DisplayMay Ann Mas
 

What's hot (20)

Branch instructions in 8051 micrcocontroller
Branch instructions in 8051 micrcocontrollerBranch instructions in 8051 micrcocontroller
Branch instructions in 8051 micrcocontroller
 
Digital design (3rd ed) morris mano
Digital design (3rd ed) morris manoDigital design (3rd ed) morris mano
Digital design (3rd ed) morris mano
 
Applications of fourier series in electrical engineering
Applications of fourier series in electrical engineering Applications of fourier series in electrical engineering
Applications of fourier series in electrical engineering
 
Project Report On 0-9 decade counter
Project Report On 0-9 decade counterProject Report On 0-9 decade counter
Project Report On 0-9 decade counter
 
Dif fft
Dif fftDif fft
Dif fft
 
Magnitude comparator
Magnitude comparatorMagnitude comparator
Magnitude comparator
 
Binary parallel adder
Binary parallel adderBinary parallel adder
Binary parallel adder
 
Interrupts
InterruptsInterrupts
Interrupts
 
Lecture 37
Lecture 37Lecture 37
Lecture 37
 
Interrupts programming in embedded C using 8051
Interrupts programming in embedded C using 8051Interrupts programming in embedded C using 8051
Interrupts programming in embedded C using 8051
 
Fast Fourier Transform
Fast Fourier TransformFast Fourier Transform
Fast Fourier Transform
 
Digital Electronics - Counters
Digital Electronics - CountersDigital Electronics - Counters
Digital Electronics - Counters
 
Chap 5
Chap 5Chap 5
Chap 5
 
TRAFFIC LIGHT CONTROL SYSTEM USING 8085 MICROPROCESSOR
TRAFFIC LIGHT CONTROL SYSTEM USING 8085 MICROPROCESSORTRAFFIC LIGHT CONTROL SYSTEM USING 8085 MICROPROCESSOR
TRAFFIC LIGHT CONTROL SYSTEM USING 8085 MICROPROCESSOR
 
Design of Elevator Controller using Verilog HDL
Design of Elevator Controller using Verilog HDLDesign of Elevator Controller using Verilog HDL
Design of Elevator Controller using Verilog HDL
 
Addition and subtraction with signed magnitude data (mano
Addition and subtraction with signed magnitude data (manoAddition and subtraction with signed magnitude data (mano
Addition and subtraction with signed magnitude data (mano
 
7-Segment Display
7-Segment Display7-Segment Display
7-Segment Display
 
8051 io interface
8051 io interface8051 io interface
8051 io interface
 
Parallel adder
Parallel adderParallel adder
Parallel adder
 
Interrupts
InterruptsInterrupts
Interrupts
 

Similar to 7 seg

arduino
arduinoarduino
arduinomurbz
 
Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10stemplar
 
Micro c lab2(led patterns)
Micro c lab2(led patterns)Micro c lab2(led patterns)
Micro c lab2(led patterns)Mashood
 
20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Jorisimec.archive
 
Debugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDBDebugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDBbmbouter
 
Itsp documentation quadcopter flight controller based on kalman filters
Itsp documentation   quadcopter flight controller based on kalman filtersItsp documentation   quadcopter flight controller based on kalman filters
Itsp documentation quadcopter flight controller based on kalman filtersJyotirmaya Mahanta
 
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Community
 
Arduino experimenters guide hq
Arduino experimenters guide hqArduino experimenters guide hq
Arduino experimenters guide hqAndreis Santos
 
Arduino experimenters guide ARDX
Arduino experimenters guide ARDXArduino experimenters guide ARDX
Arduino experimenters guide ARDXJohnny Parrales
 
NodeMCU with Blynk and Firebase
NodeMCU with Blynk and FirebaseNodeMCU with Blynk and Firebase
NodeMCU with Blynk and FirebaseEueung Mulyana
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneDavid Glick
 
GDB - a tough nut to crack: only a few bugs found by PVS-Studio
GDB - a tough nut to crack: only a few bugs found by PVS-StudioGDB - a tough nut to crack: only a few bugs found by PVS-Studio
GDB - a tough nut to crack: only a few bugs found by PVS-StudioPVS-Studio
 
Rdl esp32 development board trainer kit
Rdl esp32 development board trainer kitRdl esp32 development board trainer kit
Rdl esp32 development board trainer kitResearch Design Lab
 
Writing Performant Front-end Code
Writing Performant Front-end CodeWriting Performant Front-end Code
Writing Performant Front-end CodeLyubomir Bozhinov
 

Similar to 7 seg (20)

Led flash
Led flashLed flash
Led flash
 
arduino
arduinoarduino
arduino
 
Node.js debugging
Node.js debuggingNode.js debugging
Node.js debugging
 
Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10Ardx eg-spar-web-rev10
Ardx eg-spar-web-rev10
 
Ardx experimenters-guide-web
Ardx experimenters-guide-webArdx experimenters-guide-web
Ardx experimenters-guide-web
 
Micro c lab2(led patterns)
Micro c lab2(led patterns)Micro c lab2(led patterns)
Micro c lab2(led patterns)
 
First fare 2013 basic-labview
First fare 2013   basic-labviewFirst fare 2013   basic-labview
First fare 2013 basic-labview
 
20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris20081114 Friday Food iLabt Bart Joris
20081114 Friday Food iLabt Bart Joris
 
A Life of breakpoint
A Life of breakpointA Life of breakpoint
A Life of breakpoint
 
Debugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDBDebugging Hung Python Processes With GDB
Debugging Hung Python Processes With GDB
 
Itsp documentation quadcopter flight controller based on kalman filters
Itsp documentation   quadcopter flight controller based on kalman filtersItsp documentation   quadcopter flight controller based on kalman filters
Itsp documentation quadcopter flight controller based on kalman filters
 
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph
 
Arduino experimenters guide hq
Arduino experimenters guide hqArduino experimenters guide hq
Arduino experimenters guide hq
 
Arduino experimenters guide ARDX
Arduino experimenters guide ARDXArduino experimenters guide ARDX
Arduino experimenters guide ARDX
 
NodeMCU with Blynk and Firebase
NodeMCU with Blynk and FirebaseNodeMCU with Blynk and Firebase
NodeMCU with Blynk and Firebase
 
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting PloneWhen Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
When Good Code Goes Bad: Tools and Techniques for Troubleshooting Plone
 
GDB - a tough nut to crack: only a few bugs found by PVS-Studio
GDB - a tough nut to crack: only a few bugs found by PVS-StudioGDB - a tough nut to crack: only a few bugs found by PVS-Studio
GDB - a tough nut to crack: only a few bugs found by PVS-Studio
 
Rdl esp32 development board trainer kit
Rdl esp32 development board trainer kitRdl esp32 development board trainer kit
Rdl esp32 development board trainer kit
 
Writing Performant Front-end Code
Writing Performant Front-end CodeWriting Performant Front-end Code
Writing Performant Front-end Code
 
Arduino: Arduino lcd
Arduino: Arduino lcdArduino: Arduino lcd
Arduino: Arduino lcd
 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

7 seg

  • 1. 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 the 7 segment display on the Dragon12-PlusUSB development board. The 7 Segment display will present my birth year and name separately, since there are only four 7 segments displays. 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 & DDRP output ports, and therefore will store all 1’s or #$FF to the ports. 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 DDRP PTP PORTB is where I tell it what data I want displayed PTP is used to tell the Dragon Board which 7 SEG to use The delay portion of the code is needed, because without it I wouldn’t be able to see the numbers, 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. In this particular lab I had almost no delay, because I wanted the code to cycle so fast it would appear that all the numbers are on at the “same time”.
  • 2. Design Calculations Binary to Hex conversion a 00110111 8 4 2 1 8 4 2 1 b f a a g $ a e 3 7 = $37 c dp a a d a a # dp g f e d c b a hex 1 0 0 0 0 0 1 1 0 $06 9 1 1 1 0 0 1 1 1 $E7 8 1 1 1 1 1 1 1 1 $FF 8 0 1 1 1 1 1 1 1 $7F # dp g f e d c b a hex n 0 0 1 1 0 1 1 1 $37 I 0 0 0 0 0 1 1 0 $06 K 0 1 1 1 0 1 1 0 $76 E 0 1 1 1 1 0 0 1 $79
  • 3. Schematic Diagram of The Circuits Displaying my birthday on the 7 segment display
  • 4. Displaying my name, or one similar to it on the 7 segment display Notice I had to speed up the delay time so that there was almost no delay. This was needed to display all the 7 segments at the “same time”.
  • 5. Results (click→debug) It is clearly visible that the left picture displays 1988 and the right displays nIKE, of course I included the dots to show I am capable of using them. If our eyes could see what the code was actually presenting it would show: 8 is displayed then turned off 8 is displayed then turned off 9 is displayed then turned off 1 is displayed then turned off repeat 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. Problems Encountered This lab was particularly confusing, because it used 2 output ports. I had a hard time wrapping my head around which port does what. I now understand and clearly explained it in the theory section. This is because I am used to programming using Arduino, which I would define the pins as an output in the beginning, but I can also write data to that same pin (ie. Pin 1). I also wanted to actually display all four 7 segments at the same time. I am not able to do this, because I keep rewriting to PTP, which erases the data from the last instruction. In order to accomplish turning all the 7 segment displays at the same time each display would need its own port.
  • 6. Conclusion I have used some basic assembly commands to utilize the 7 segment displays. 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.