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

AWK programming, I have 9 assignments to be completed

I have 9 assignments to be completed

Define a prolog predicate that asserts list, Define a Prolog predicate flat...

Define a Prolog predicate flatten(List, FlattenedList)  that asserts List  is any nested list of atoms and  FlattenedList  is the same list with the nesting removed. The atom [] sh

Code html and xml, Topic Develop a Web site that will provide informat...

Topic Develop a Web site that will provide information about your organization. The Web site will need to have a user-friendly interface for users to enter their information;

Create xml document to save calendar information, Prepare an XML document t...

Prepare an XML document that contains calendar information such as the following text describes: The calendar is owned by a person (e.g. John Smith) and has a few paragraphs tha

Asp.net support for ajax and javascript intellisense, ASP.NET Support for A...

ASP.NET Support for AJAX and JavaScript IntelliSense IntelliSense for Enthusiasm JScript makes it accessible client-script selection components in the value manager in Vision Facil

Prolog predicate for list that contains duplicate elements, Write a Prolog ...

Write a Prolog predicate  has_duplicates(L)  that is true if list  L  contains duplicated elements (that is at least 2 copies of an element). For instance: ?- has_duplicates([a,

Matlab homework, Matlab Assignment # For each of the three datasets (data1....

Matlab Assignment # For each of the three datasets (data1.txt, data2.txt, and data3.txt in bnhw2q2.zip), cluster the data using k-means in Matlab, with k=2, 3, 4 and 5 using the pr

Matlab, Determine the moment of force about the point where a bracket is at...

Determine the moment of force about the point where a bracket is attached to a wall. the bracket is shown in figure attached. it extends 10 inched out from the wall and 5 inched up

Program for hold details of all the cabins for travellers, Scenario A ca...

Scenario A campsite provides cabins for travellers to stay in overnight. A 'cabin' is a small wooden hut, containing bunk beds, table and chairs, a heater, and a small cookin

Assignment about prolog, Hi I have an assignment for prolog languagle is ...

Hi I have an assignment for prolog languagle is it possible to get help

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