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

Write a shell script to find the maximum of three numbers, W.A.S.S to find ...

W.A.S.S to find the maximum of three numbers Program # W.A.S.S to find the maximum of three numbers echo "Enter three No.:" read no1 read no2 read no3 if test $no1 -gt $n

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

Shell script to print count & sum of digits of given number, Normal 0 ...

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

Pattern matching program in xhtml, Part 1 Given the following Regular Exp...

Part 1 Given the following Regular Expressions, explain in detail the pattern accepted by each. Pay attention to all the characters being used. Your answers need not appear with

Shell script to print pyramid, Normal 0 false false false ...

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

Computer games development, Lazytown Constabulary are concerned that young ...

Lazytown Constabulary are concerned that young people in the town are unaware of the sorts of crime that they might encounter in their daily lives and are concerned that they may b

C# not c++ programing help, Please write a program declaring a variable x a...

Please write a program declaring a variable x as the type int, and use the scanf function to input an integer to initialize the value of x. Then, your program will print the follow

Write an xslt-flatten the tree, Flatten the tree Consider the followin...

Flatten the tree Consider the following XML input, which groups people into two categories-salaried and hourly: Warren Rosenbaum 37 5.75

Explain the break statement - computer programming, Explain the Break State...

Explain the Break Statement - Computer Programming? The break statement is used as an interrupt to the normal flow of control this statement causes as exit from the switch stat

Brent''s method, This is what I have so far def root_brent(f, a, b, errorl...

This is what I have so far def root_brent(f, a, b, errorlimit = tinyerror, n = -1, r_i = 0): # f(a) and f(b) must have opposite signs poly = remove_multiple_roots(poly) counter

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