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

General Programming , #questCustomers of a particular restaurant are descri...

#questCustomers of a particular restaurant are described with some categories. If the categories indicate the customer is a senior citizen, or the customer works for the restaurant

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;

Classroom management, A partly completed project Cwk 4-students is availabl...

A partly completed project Cwk 4-students is available for downloading from Studynet Assignments. You are required to amend this BlueJ project to implement a version of the WHEN sy

Write a recursive function to generate anagrams, An anagram is a type of wo...

An anagram is a type of word play, the result of rearranging the letters of a word or phrase to produce a new word or phrase. For example the anagram of tea is tea, tae, eat, eta,

Pascal, Problem Solving 1. Write Pascal code that accepts as input the nam...

Problem Solving 1. Write Pascal code that accepts as input the names of the students, course work score and exam score for a unspecified number of students who have taken a subjec

Script of switch case, Write a script called 'prob3.m' that does the same t...

Write a script called 'prob3.m' that does the same thing as the previous question except that it makes use of a switch-case construct instead of an if-else. In the file 'hw4.m'

Introduction to javascript, This is the programming language of the Web. It...

This is the programming language of the Web. It is mainly used for validating forms. JavaScript & Java can be associated to each other. There exist several other differences betwee

System calls, #questiWrite down different system calls for performing diffe...

#questiWrite down different system calls for performing different kinds of tasks.on..

Pl sql project, create a small database for a company, require at least 4 t...

create a small database for a company, require at least 4 tables. also, have 4 business report, oracle built-in function, 5 string, 5 number or math functions, 5 date and time func

Count the total number of records in data table, Normal 0 false...

Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

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