Input output program, Programming Languages

Assignment Help:

Problem Specification

I/O programming is the \bread and butter", the raison d'etre, of microcontrollers. After all, our definition of a microcontroller is \a microprocessor with on-board I/O systems".

So let's get your hands dirty with some I/O programming so that you feel comfortable with the concepts of a memory-mapped I/O architecture, interacting with the I/O systems on the Dragon-12+ board and handling interrupts.

Our basic program will continuously read the value of channel 5 of the ATD converter, perform an 8-bit conversion on that value and output it two difierent ways. First, output the converted value on SCI1. Second, light up LEDs on Port B proportional to the maximum value. Details for both of these requirements can be found below. You must use interrupts for reading the ATD converter values, but can choose polling or interrupts for the SCI.

Software Requirements

You must write software for the HCS12 in assembly language that accomplishes the following things:

 Sets up all of the ports appropriately.

{ Making all the bits of Port B output bits.

{ Making the LEDs work on the Dragon-12+ board by executing a movb #2,DDRJ instruction.

 Set up all SCI1 parameters

{ Enabling the transmitter

{ Enabling transmitter interrupts (if you choose to use them)

 Set up all ATD parameters

{ Powering up the converter

{ Configuring 8-bit conversions on channel 5, one channel but continuous conversions

 Spin in an in finite loop until an ATD \sequence complete" interrupt res.

 Read the value from the result register.

 Convert this value into characters for transmittal. (See below.)

 Further convert this value to light up the LEDs proportionally. (Again, see below.)

 Do this operation forever. However, you should only write a new value out to the SCI Terminal when the value changes.

I will test your program by running it in the simulator and \play around" with the analog inputs to verify that the above requirements are met.

SCI Character Conversion

We cannot simply send the raw result from the converter out to the SCI, because it is a character device. This means it is designed to work with ASCII values, not raw binary. For instance, consider that the value from the ATD converter was $45. If you simply transmitted this value, instead of seeing the text 45 show up on the Terminal, you would see a single character E. So we need to convert the value into a sequence of characters. We would need to have a $34 for the character 4 and a $35 for the character 5. Doing this for hexadecimal values is a little more complex than we want to deal with, so you should output decimal values instead.

For an 8-bit value, our values range from 0 ! 255. We can convert any of those values into a sequence of characters by dividing the original value first by 100. The quotient is the hundreds digit (but don't throw away the remainder yet). To make the hundreds digit into a character, simply add $30. We can then take the remainder and divide it by 10 to get the tens digit. Again, add $30 to make it a character. Finally, take that remainder and add $30 to get the ones digit. (You can divide by 1 if you really, really want to.) A few subroutines have been provided for you for printing null-terminated strings to the terminal, but it will be up to you to make your code work with them.

Character Conversion Example

Consider the value $7D or 125. It needs to be turned into $31, $32, $35. We divide by

100 and get a quotient of 1, remained of 25. Add $30 to the 1 to get the first character.

Divide the remainder of 25 by 10 to get a quotient of 2, remainder of 5. Add $30 to each of these.

LED Illumination

The basic idea here is to light up more LEDs as the analog input value gets higher, like the volume control on a TV. It can't just be writing the converted value to the LEDs, because some large numbers (for example, $80) have very few ones in their binary representation. We need to map the value into ranges where we light up more and more LEDs. The required ranges are as follow:

 $00 ! $1F: Light up PB0 only.

 $20 ! $3F: Light up PB1,PB0.

 $40 ! $5F: Light up PB2, PB1, PB0.

 $60 ! $7F: Light up PB3, PB2, PB1, PB0.

 $80 ! $9F: Light up PB4, PB3, PB2, PB1, PB0.

 $A0 ! $BF: Light up PB5, PB4, PB3, PB2, PB1, PB0.

 $CE ! $DF: Light up PB6, PB5, PB4, PB3, PB2, PB1, PB0.

 $E0 ! $FF: Light up all LEDs.

Clearly this is something you could do with a case construct, or there might be a clever way of calculating the output arithmetically (I haven't really thought about it myself).

Extra Credit

To earn a few extra points, if you print the value of the result from the ATD Converter in hex (including the $ prefix).

Considerations

1. How did you code the LED illumination rules? Why did you choose this method?

2. Were the provided SCI subroutines helpful? Why or why not?

3. How could you change the SCI Character Conversion rules to print out hexadecimal values instead?

4. What was the hardest part of this assignment?


Related Discussions:- Input output program

CMIS 102, Calculate the total price based on several key parts required to ...

Calculate the total price based on several key parts required to build a state-of-the-art gaming computer. The user will have the option of selecting different parts.

assembly lang. H.W, 1- Allocate array with 32bit 100 element 2- Prompt the...

1- Allocate array with 32bit 100 element 2- Prompt the user to enter the maximum or the upper bound of the random value 3- Read the value and use it generate random numbers to init

Corba multiple clients, I have an assignment that requires from me to run ...

I have an assignment that requires from me to run multiple clients and one server ( Corba)

Create a fortran program for represent a convex polygon, In analytical geom...

In analytical geometry, a convex polygon can be represented by the Cartesian coordinates of its vertices, x and y. Assume such data of a polygon are stored in a file called "vertic

Read file in Perl, These are the specifications for your Perl program: 1. ...

These are the specifications for your Perl program: 1. The file containing your program must be named cookiemgr.pl 2. It must be invoked as: cookiemgr.pl cookies_file [options]

Board coloring problem description, Board Coloring Problem Description ...

Board Coloring Problem Description In this problem you are given a board in which some of the elements are placed as shown in diagram below. Each element represents a color.

Java, non restoring division

non restoring division

Programme for create the class in the karel++ , Create the class Robot desc...

Create the class Robot described in the Karel++ book. Description: The Robot class described in the Karel++ text is a derived class of ur_Robot. Create class Robot as a d

Application in pascal language for free pascal compiler , Before I describ...

Before I describe what you are supposed to do, please remember that this programming assignment is NOT a group project. You are NOT allowed to do this with anyone else's help. This

Class Project, I need help getting started with a class project of creating...

I need help getting started with a class project of creating a project in the Perl programming language. I was thinking of maybe doing an employee directory

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd