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

C programming, write a function that raises an integer to a positive intege...

write a function that raises an integer to a positive integer power. call the function x_to_the_n taking two integer arguments x and n. have the function return a long int, which r

Advance operating systems, Project2: A Simple Distributed Computing Platfor...

Project2: A Simple Distributed Computing Platform (Due at 11:59:59pm on 04/12/2012 (EST)) Description: You are asked to develop a replicator (client) that distributes a large job

Create an application to run in the amazon ec2 service, In this assignment ...

In this assignment you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application. You

Define parameter passing mechanism - computer programming, Define the Param...

Define the Parameter Passing Mechanism - Computer Programming? The Parameters are syntactically identifiers and they are used within the body of the function and sometimes the

Jsp project, Eclipse Jsp Project. I am making a a project on my website and...

Eclipse Jsp Project. I am making a a project on my website and i was making a help support page on which the user can submit their question and the question is saved to a text file

Read Multiple Text Files, How to read datasets in multiple text files in an...

How to read datasets in multiple text files in an non interactive program?

Advantages of java stored procedures, Advantages of java stored procedures ...

Advantages of java stored procedures Transactions Although a saved process contains SQL orders, once collected it will socialize with SQL Hosting server very diversely from

Microprocessor, what is a microprocessor? types of microprocessors? advanta...

what is a microprocessor? types of microprocessors? advantages disadvantages

About oracle, do you solve questions of assigments?

do you solve questions of assigments?

Create a one to two page html document, Task 1 Think about a Web site...

Task 1 Think about a Web site you would like to work on for Assignment 2. For example, you can do a personal interest site, a site for your favourite nonprofit organization,

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