Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part A: For this part, you must write Assembly Language that will turn ON LEDs 1

ID: 3565162 • Letter: P

Question

Part A:
For this part, you must write Assembly Language that will turn ON LEDs 1 to 4 when push
button PB1 is pushed. The program must turn ON LEDs 5 to 8 when push button PB2 is
pushed.
PB1 is wired to Port A0, PB2 is wired to Port A1. Both these pins must be configured as input
pins.
The LEDs 1 to 8 must be wired to Port B.
LED8 to PortB0
LED7 to PortB1
LED6 to PortB2
LED5 to PortB3
LED4 to PortB4
LED3 to PortB5
LED2 to PortB6
LED1 to PortB7
You must write the code in HCS12 Assembly Language and run it first in Full Chip Simulation,
and, in the lab, download it in the board
Part B:
In this part, you are required to write C code in CodeWarrior to perform Analog to Digital
conversions. When your code starts running, you must perform one A/D conversion and store
the value.
Subsequently, you will perform A/D conversions and subtract from them, the initially stored A/D
value. Once this is done, you must output the value to Port B which will be wired to the 8 LEDs
on the prototyping board. Vary the applied voltage and observe the LEDs. Start your program
under different initial applied voltages

Comment your code. Once you have your code working and demonstrated to your TA, modify it
to control the 8 LEDs based on the following logic:
If A/D value-initial value is between 00000000 and 00011111, turn on LED 0
If A/D value-initial value is between 00100000 and 00111111, turn on LED 1
If A/D value-initial value is between 01000000 and 01011111, turn on LED 2
If A/D value-initial value is between 01100000 and 01111111, turn on LED 3
If A/D value-initial value is between 10000000 and 10011111, turn on LED 4
If A/D value-initial value is between 10100000 and 10111111, turn on LED 5
If A/D value-initial value is between 11000000 and 11011111, turn on LED 6
If A/D value-initial value is between 11100000 and 11111111, turn on LED 7
You must try out your code, on the simulator, before you come to the lab.

Explanation / Answer

Part A: Assembly Language that will turn ON LEDs 1 to 4 when push button PB1 is pushed.

Part B: C code in CodeWarrior to perform Analog to Digital

This Method will also be useful.