ABC Consolidated Financial InfoABC Company's current financial information (before/without expansion)Dec. 31,20X2Dec. 31,20X1Cash$ 50,000$ 70,000Accounts receivable (net)$ 120,000$ 180,000Merchandise inventory$ 350,000$ 280,000Property plant, & equipment$ 400,000$ 300,000Less: Accumulated depreciation$ (170,000)$ (100,000)Total assets$ 750,000$ 730,000Accounts payable$ 250,000$ 210,000Income taxes payable$ 40,000$ 10,000Common stock$ 240,000$ 240,000Retained earnings$ 220,000$ 270,000Total liabilities & stock, equity$ 750,000$ 730,000The firm's accrual-basis income statement revealed the following data:Sales$ 1,200,000Cost of goods sold$ 800,000selling and administrative expenses$ 250,000Depreciation expense$ 70,000Income taxes$ 30,000Dividends declared and paid during 20X2$ 100,000ABC purchased $100,000 of equipment for cash on August 14, 20X2(There was no interest expense.)
ABC Product informationBased on Chapter 5's exercise 5ABC's Product informationCurrent ProductExpansion Product (estimate)Selling Price$14.50?Units produced and expected to be sold80,0005,000Machine Hours40,0005,000Direct Materials$1.30 per unit$5.60 per unitDirect labor dollars needed per product$2.80 per unit$4.00 per unitVariable Factory Overhead$1.00 per Machine Hour$1.00 per Machine HourVariable Selling Expense$0.20 per unit$0.20 per unitTotal Fixed Costs:Fixed Factory Overhead$ 198,000Fixed Selling expenses$ 191,250
UNIVERSITY OF CALIFORNIA, SANTA CRUZ
BOARD OF STUDIES IN COMPUTER ENGINEERING
CMPE13/L: INTRODUCTION TO PROGRAMMING IN C
Lab 1: Compiling, Running, and Debugging
Introduction
This is the first lab in CMPE13. Here we will demonstrate the basics of compiling and running C
programs in the simulator and on the Uno32 hardware. We will also explore the tools we will
use and some of their features for debugging problems you might encounter.
Reading
• Document on compiler errors
• Document on Unix and Git
• Document on software installation (if you want to run everything on your own computer)
• Document on style guidelines
• Document on MPLAB X
• Document on serial communications
• K&R Preface and Introduction
• K&R Sections 1.0-1.2, 4.5, 4.11
Provided Files
• part1.c: This file contains code that performs a simple sorting algorithm on five randomly
generated numbers. Follow the setup procedures listed below, add the requested
documentation, and format the code to follow the provided style guidelines.
• part2.c: This file contains an empty main() to be filled with the exercises from section 1.2 of
K&R. In addition, you will be asked to modify these exercises to add some additional
functionality. Detailed steps are listed below.
• BOARD.c/h - Contains initialization code for the UNO32 along with standard #defines and
system libraries used. Also includes the standard fixed-width datatypes and error return values.
You will not be modifying these fi.
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
ABC Consolidated Financial InfoABC Companys current financial inf.docx
1. ABC Consolidated Financial InfoABC Company's current
financial information (before/without expansion)Dec.
31,20X2Dec. 31,20X1Cash$ 50,000$ 70,000Accounts
receivable (net)$ 120,000$ 180,000Merchandise inventory$
350,000$ 280,000Property plant, & equipment$ 400,000$
300,000Less: Accumulated depreciation$ (170,000)$
(100,000)Total assets$ 750,000$ 730,000Accounts payable$
250,000$ 210,000Income taxes payable$ 40,000$
10,000Common stock$ 240,000$ 240,000Retained earnings$
220,000$ 270,000Total liabilities & stock, equity$ 750,000$
730,000The firm's accrual-basis income statement revealed the
following data:Sales$ 1,200,000Cost of goods sold$
800,000selling and administrative expenses$
250,000Depreciation expense$ 70,000Income taxes$
30,000Dividends declared and paid during 20X2$ 100,000ABC
purchased $100,000 of equipment for cash on August 14,
20X2(There was no interest expense.)
ABC Product informationBased on Chapter 5's exercise 5ABC's
Product informationCurrent ProductExpansion Product
(estimate)Selling Price$14.50?Units produced and expected to
be sold80,0005,000Machine Hours40,0005,000Direct
Materials$1.30 per unit$5.60 per unitDirect labor dollars needed
per product$2.80 per unit$4.00 per unitVariable Factory
Overhead$1.00 per Machine Hour$1.00 per Machine
HourVariable Selling Expense$0.20 per unit$0.20 per unitTotal
Fixed Costs:Fixed Factory Overhead$ 198,000Fixed Selling
expenses$ 191,250
UNIVERSITY OF CALIFORNIA, SANTA CRUZ
BOARD OF STUDIES IN COMPUTER ENGINEERING
2. CMPE13/L: INTRODUCTION TO PROGRAMMING IN C
Lab 1: Compiling, Running, and Debugging
Introduction
This is the first lab in CMPE13. Here we will demonstrate the
basics of compiling and running C
programs in the simulator and on the Uno32 hardware. We will
also explore the tools we will
use and some of their features for debugging problems you
might encounter.
Reading
• Document on compiler errors
• Document on Unix and Git
• Document on software installation (if you want to run
everything on your own computer)
• Document on style guidelines
• Document on MPLAB X
• Document on serial communications
• K&R Preface and Introduction
• K&R Sections 1.0-1.2, 4.5, 4.11
Provided Files
3. • part1.c: This file contains code that performs a simple sorting
algorithm on five randomly
generated numbers. Follow the setup procedures listed below,
add the requested
documentation, and format the code to follow the provided style
guidelines.
• part2.c: This file contains an empty main() to be filled with
the exercises from section 1.2 of
K&R. In addition, you will be asked to modify these exercises
to add some additional
functionality. Detailed steps are listed below.
• BOARD.c/h - Contains initialization code for the UNO32
along with standard #defines and
system libraries used. Also includes the standard fixed-width
datatypes and error return values.
You will not be modifying these files at all!
• Oled.c/h, Ascii.c/h, OledDriver.c/h – These files provides all
the code necessary for calling the
functions in Oled. You will only need to use the functions in
Oled.h, the other files are called
from within Oled Library. You will not be modifying these files
at all!
4. Assignment requirements
0. Perform “Hello World” with the UNO32
1. Complete the requested modifications to this code.
o Complete the setup procedures
o Add the requested documentation to a README.txt file
o Format the code to follow the provided style guidelines
2. Complete the temperature conversions tables based on code
provided.
o Implement code to output a table of equivalent Fahrenheit and
Celsius values.
o Extend this code to also output a table of equivalent Kelvin
and Fahrenheit values.
o Format the code correctly according to the style guidelines.
3. You will implement a simple module to implement two very
simple functions. Detailed steps are
listed below.
4. Extra credit: “Hello World!” on the OLED.
Grading
This assignment consists of 12 points:
• Two points for Part 0
5. • Four points for Part 1
• Four points for Part 2
• Two points for Part 3
• One point of extra credit
Note that you will lose points for any and all code that fails to
compile!
Part 0 – “Hello World”
All programming languages have a “hello world” program1.
This program is generally simple as possible
and demonstrates that both the code and system runs. While the
“Hello World” performed on the
UNO32 prints “Hello World,” other embedded systems might
have a blinking LED to indicate success.
1 In fact, this is true for all languages because K&R states so at
the beginning of chapter 1: “The only way to learn a
new programming language is by writing programs in it. The
first program to write is the same for all languages:
Print the words
1. Follow the MPLAB X new project instructions (link) to
generate a project for this part. I would
suggest working with the git repository2. We have seeded your
repo with folders for each lab.
When the graders pull labs this is where they will be pulled
from.
6. 2. Right-click on source files and click on New->Other…
a. Choose Microchip Embedded-> XC16 Compiler and select the
mainXC16.c file (We’re not
using the XC16 compiler, but this will generate the correct file
anyway). Click “Next.”
b. Name the file Part0 and click “Finish”. This will generate a
new main file for the project.
i. Remember for future reference that only one file with a
main() function can be
added to your project at a time.
c. Make the contents of this file appear as those shown below
3. Go into project properties and navigate to simulator->Uart1
IO Options and check Enable Uart1
IO.
4. Now press the “Debug Main Project” button: . This will run
your code inside the
simulator.
a. If this fails for some reason and your code looks exactly the
same as shown, make sure
you go back and check the new project document.
b. If it still does not work and you have followed the new
project instructions, get help
from the teaching staff.
5. At the bottom of the window will be an Output tab. One of its
subtabs will be title "UART 1
Output", selecting this will show the serial terminal output. It
7. should show the words “Hello
World” showing that we have successfully ran the hello world
program.
6. Click on to stop the program and continue working.
7. Now that we have successfully run the code on the simulator
we can run the code on the
UNO32 itself. This process is started by plugging in both USB
cables that came with your kit into
the computer.
hello, world
This is a big hurdle; to leap over it you have to be able to create
the program text somewhere, compile it
successfully, load it, run it, and find out where your output
went. With these mechanical details mastered,
everything else is comparatively easy.”
2 This symbol designates a good place to commit in the process.
This should get you used to commiting early
and often.
G
G
G
https://classes.soe.ucsc.edu/cmpe013/Spring15/Labs/CMPE13_
MPLABXNewProjectInstructions.pdf
8. 8. Once the drivers have installed themselves go back into the
project properties.
a. To program the UNO32 the only change needed is to select
PICkit3 as shown below:
b. Hit “OK” and exit out of the project properties. Don’t worry
about the SN as each PICkit3
has a unique one.
c. We can now hit the Make and Program Button ( ) to load the
code onto the
UNO32. To actually see the output you will need to setup a
serial port as described in
https://classes.soe.ucsc.edu/cmpe013/Spring15/Labs/CMPE13_S
erialCommunications.p
df
d. Once the serial port is setup you can hit the program button
and MPLAB-X will load the
code onto the UNO32 and run it.
i. If you encounter any errors, recheck the serial port
documentation.
ii. Note that sometimes there are issues with the PICkit3
connecting.
iii. If it is still not working, contact the teaching staff.
e. You should now see “Hello World!” on your serial program
window.
Part 1 – Debugging and Code Style
9. 1. No hardware needs to be connected yet.
2. Create a new project in MPLAB X using the new project
guide being
sure to select the simulator. Name the project something that
makes sense like “Lab1_part1”.
3. Go Into project properties and navigate to simulator->Uart1
IO
Options and check Enable Uart1 IO as was done in the previous
https://classes.soe.ucsc.edu/cmpe013/Spring15/Labs/CMPE13_S
erialCommunications.pdf
https://classes.soe.ucsc.edu/cmpe013/Spring15/Labs/CMPE13_S
erialCommunications.pdf
section.
4. Add part1.c to the project (Right-click on the "Source Files"
folder in the project window
obtainable from View -> Project)
5. Build the project by clicking the hammer on the toolbar. This
will result in a
"Lab1_part1.X.production.hex" file under
"Lab1_part1.Xdistdefaultproduction"
a. You should see black “BUILD SUCCESSFUL” text at the end
of a successful build. A failed
10. build will show a red “BUILD FAILED” message. Get help if
your build fails for part 1.
6. Now press the “Debug Main Project” button: . This will start
the simulator.
a. Debug controls, in order: Debug, Stop, Pause, Reset,
Continue
7. Press the pause button. It should be located to the right of the
“Debug Main Project” button.
The debugger should be stopped on the final while(1); at the
end of the code. A green bar
with an arrow on the side is used to indicate the line of code the
debugger has paused at (this
line of code has not been executed yet).
8. At the bottom of the window will be an Output tab. One of its
subtabs will be title "UART 1
Output", selecting this will show the serial terminal output. It
should be a sorted list of five
numbers, like the following: "[46, 92, 105, 174, 212]".
9. Press the reset button in MPLAB (the blue one with two
arrows). This will reset the debugger to
the start of main() and stay paused. Don't press play quite yet.
10. Place a breakpoint on the first line inside the curly braces of
11. the first for-loop (line 85). Do this
by clicking the line number in the left margins of the source
code view. It should place a red
square on the line number and highlight the whole line red.
Placing the breakpoint inside the
for-loop ensures that the debugger will stop before every
iteration of the loop. Note that you
G
may only have 4 breakpoints active at a given time.
a. Removing a breakpoint is done by pressing the red square
again.
11. Now press play. The debugger should pause at the top of the
for-loop, changing that line to
green and showing a green arrow in the left margin.
12. Below the code window should be a number of tabs. Click
the one labeled “Variables”. This tab
shows the values of all variables within the scope of where you
are paused. It will be updated
whenever the program is paused, but not when it is running.
13. Find the array valsToBeSorted. You can expand it to see the
12. value of every element of the
array by clicking the plus-sign/arrow next to it.
14. Right-click on the valsToBeSorted and select “Display
Value Column As” -> “Decimal” to see
everything as base-10.
15. Record the values of the elements in valsToBeSorted in a
new file, README.txt.
a. Also place your name at the top of the README.txt, along
with the names of anyone
you collaborated with.
16. Press play. It should stop at the top of the for-loop again.
Record the values of valsToBeSorted
again in your README.txt file and repeat 4 more times (the
breakpoint will not be hit on the last
run).
G
17. After the last run through the loop it will continue to the
end of the program and will not hit the
breakpoint we placed. The final sorted result of the array will
be shown in the Output tab under
13. the UART 1 Output sub-tab.
18. Complete Task 1 - Add documentation
Add a comment directly above the sorting for-loop, but below
the comment that says "Sort the
array in place", listing the 5 recorded values of valsToBeSorted
from the last run (some may
be the same, but list them anyways).
19. Complete Task 2 - Correct formatting
a. part1.c does not conform to the dictated style guidelines.
While we could fix the source
code manually MPLAB X has the capability to reformat the
code for us. Press “Alt-Shift-
F” and watch as MPLAB-X fixes all the code for you.
b. After saving the properly formatted Part1.c we can view the
history of this file by right-
clicking on the filename in the bar and selecting Local History -
> Show Local History.
This brings up the interface as shown below.
c. Clicking on any of these dates will compare the current file to
its content when it was
saved. (Note that this history is local to the computer and by
14. default only lasts 7 days)
d. Similarly if instead of selecting Show Local History we click
on Diff To… we can compare
it to an arbitrary file. In this case we can compare it to the
Part1.c before we started by
using a fresh copy of the file.
e. Open up this diff and record the line numbers where changes
were made to the code,
not the comments, to your README.txt.
Part 2 – Temperature Conversion
1. Standard Conversion Table
a. Create a new MPLAB project named Lab1_part2 following
the same procedure as in Part 1
i. Don’t forget to enable the additional warnings in the compiler
options!
ii. Make a new subfolder to keep things nicely organized.
G
G
G
15. b. Add the provided "part2.c" in it to your new project
c. Implement the code example below3. Type out the code
between the comments that say
“Your code goes in between this comment and . . .” in your
part2.c file.
d. Compile and run your code in the simulator by clicking the
debug button that you used for
part 1. Now check that your output looks similar to the
following output:
e. Fix the coding style for this code such that it follows the
provided Style Guidelines. To do
this, select all of the code and click Source -> Format (or alt-
shift-F) to allow MPLAB X to
automatically fix the formatting. Note the differences between
the formatted and
unformatted code (use Edit -> Undo and Edit -> Redo to
compare or use the local history as
in part 1).
3 Note that this is example is from K&R 1.2, please reread this
section before attempting part 2 of the lab.
16. G
G
G
f. Change the display format (currently "%f") of the Fahrenheit
value so that it has a minimum
width of 7 characters and a precision of 1. Also change the
display format of the Celsius
value so that it has a minimum width of 4 characters, it's left-
padded with 0s, and displays
no characters after the decimal point.
i. To see an explanation of these format specifiers, click on
printf() in your code,
and press CTRL+SPACE to bring up Code Assistance, and
scroll down to the bullet
points. To see examples, scroll all the way to the bottom. Code
assistance can also
be used for auto-completion, which we will later see.
ii. You can also access this information through help in MPLAB
X as well. Go to “Help”
17. ->”Help Contents”->”XC32 Toolchain”->”XC32 Standard
Libraries”->”Standard C
Libraries with Math”->”<stdio.h> Input and Output”->”STDIO
Functions” and find
printf (note that we think ctrl-space is simpler).
g. The output should now look as follows:
G
2. Column Headers
a. Add column headers to above the Fahrenheit-to-Celsius table
with the letters ‘F’ and ‘C’ spaced nicely using the printf()
function you read about in the MPLAB X help. This header
should
be printed only once and be before any of the conversions are
calculated and printed.
3. Kelvin to Fahrenheit Table
a. Now print a newline character after the Fahrenheit-to-Celsius
table by typing prin, press CTRL+SPACE, and then press
ENTER to
18. auto-complete4 into printf(). Use the string "n" to add a
blank line in the output.
b. Now make a Kelvin to Fahrenheit conversion table, complete
with
its own header. This can be done by selecting the block of code
that you modified:
4 Auto-complete, that is typing the first few characters and ctrl-
space is you friend; this will complete function
names, variables, members of structs, #defines, pretty much
anything defined in scope in the current project. It is
incredibly useful, use it often.
G
G
Then copy (Edit -> Copy), and paste (Edit -> Paste) the code
below the printf() you
just added.
i. Rename the variable fahr by selecting the pasted block of
code, and click
19. Edit -> Replace. For “Find What:” type fahr, and for “Replace
With:” type
kelv. Click “Replace All”, and Close.
ii. Notice how the kelv variable was not defined (MPLAB X
underlines it in red). To
fix this, declare it as a float by adding float in front of
“kelv=lower;”.
iii. Now replace celsius with fahr in the same block of code.
Next, modify the
line “fahr = … “ by changing the expression to convert from
kelvin to
Fahrenheit.
iv. Now format the table to look like the image on the previous
page. The Kelvin
values should be displayed in the left-hand column with a
minimum width of 3
characters, left-padding with zeros, and a precision of 3. The
Fahrenheit values
should be displayed in the right-hand column with a minimum
width of 5
characters.
c. Note that a compiler error will occur if two variables of the
same name are declared.
20. You need to have unique names for all variables within a single
scope (scope will be
explained later, but for this part of the lab you will need unique
names for all variables
you use). You can reuse your variables from the first table for
generating the second
table, just make sure that the “float fahr…” and “int lower,…”
lines only appear once at
the top5. Also you should make sure that your variable names
make sense with the
values that they store6; for instance, you should use a variable
named kelv to store the
calculated Kelvin values.
d. Refactoring (renaming) variables and functions is another
useful feature in MPLAB X.
You decide that kelv should be renamed to kelvin in your code.
Click on kelv
anywhere in your code, and click Refactor -> Rename, and type
kelvin. This renames
the variable everywhere in the project! Be careful when using
refactor.
e. Again view the output in the UART 1 Output tab of the
Output window. The final output
21. of the program should look like the picture above.
5 In general, putting all of your variables at the top of your
function is a very good practice.
6 Good naming of variables and functions is a key part of
software design, start practicing it now.
G
G
Part 3 - #include directives and Modules
In this section you are going to learn to build your first module
(which is a .c and a .h file
that each share the same name) in order to implement two very
simple mathematical
functions. Note that these are really simple functions that you
would never implement
this way, but serve to get you used to using functions and how
to call them.
The two functions are: IncrementByOne and AddTwoNumbers.
Before we get into the nuts and bolts of implementing these, we
22. need to know what a
module in C is. Basically, a module is a pair of files [.c,.h]
which are called the “header
file,” which ends in “.h” and the “source file” which ends in
“.c” which are added to a
project to encapsulate the functionality of the code into a
common holder. The
advantage of this form is that is separates how to use the
functions (instructions in the
.h) versus how the functions are implemented (in the .c). This is
particularly useful in
complicated projects or where several people are working on the
same code, as it
enforces partitioning the problem into smaller parts. A useful
analogy is that the .h file
contains a contract between the end user and the programmer on
how to use the
functions. As long as the user abides by this contract, the
programmer is free to change
his/her code without causing the users code to fail.
In order to explore the functionality of a module, we’re going to
first have you use the
built-in math functions of C in order to test the functions, and
23. then later you are going
to use your own functions that you write yourself. This example
is trivial, but
demonstrates how to use functions.
Make a new project with the part3.c file provided, and uses the
two math operators +
and ++. These correspond to addition and (post) increment.
They are used as:
z = x + y;
x++;
which is to say that the first line adds two numbers, sets a
variable with the result. The
second line increments a variable. What we are going to want to
do is modify the hard
coded numbers in there, and run both the addition and increment
and make sure you
believe the numbers. As a point of interest, keep everything in
integer variables.
24. Once you convince yourself that the math functions are
working, and you have a decent
test capability, then we are going to substitute our own
functions for the ones (in this
scenario, we are going to assume that the normal operators are
not available).
In order to implement these two functions, we first need to
define how the functions
are going to work. In the case of the AddTwoNumbers function,
we take in two integer
values and returns the sum. In order to specify this to C, we will
declare a function
prototype that looks like this:
int AddTwoNumbers (int y, int x);
For the IncrementByOne, we are going to need only a single
integer input, and the
function returns a single integer. We are actually going to
implement this by using the
other function we’ve created (that is, a function will call
another function). Again, to
specify this in C, we are declare:
25. int IncrementByOne (int x);
Putting this together into a header file, we are going to have a
full header file that looks
like this:
/* module containing implementations of AddTwoNumbers and
IncrementByOne */
#ifndef SIMPLEMATH_H
#define SIMPLEMATH_H
int AddTwoNumbers (int y, int x);
int IncrementByOne (int x);
#endif
This should go in a file named: SimpleMath.h
In order for your code (in main.c) to use these functions, you
will have to include your
header file (the source file will get included automatically) by
using the C-preprocessor
directive: #include “SimpleMath.h”
Note that you will need the #include line inside the
SimpleMath.c as well in order for it
26. to compile. This is because C requires that all functions (and
variables) be declared
before they are used.
Now, onto the implementation, which will go into the
SimpleMath.c file. Let’s tackle the
Add Two Numbers first, since it should be more familiar.
We are just going to implement the addition within a function
(sometimes very simple
functions are known as wrappers or wrapper-functions).
The increment by one function is going to accomplished by
calling the add two numbers
function with one of the arguments set to 1. That is:
IncrementByOne(x) ↔ AddTwoNumbers(x,1)
If you wanted a helper function, you would put that as a private
function within the .c
module. This helper function can be used by both of your
functions, yet is fully
contained within the .c file (thus not exposed to the world). In
order for the compiler to
27. be happy, inside the .c file you will need both the function
prototype and the function
declaration itself. The function prototype tells the compiler how
much space to set
aside, and lets you give it the rest of the details (actual code)
later. Lets say you needed
a function of Bigger, which would return the bigger number. In
this case the prototype
will look like:
G
G
int Bigger(int x, int y);
This should be up near the top of the .c file. The function itself,
is going to appear
farther down in the file (lets go ahead and put at the end of the
.c file), and is going to
look like:
28. int Bigger(int x, int y)
{
// you get to fill this in
}
Note that there are no semicolons at the end of the function.
Once you have this
function written, you will need to test it. It should work for any
two integer numbers,
positive and negative number, and also for 0.
Now go ahead and implement the other two functions
(IncrementByOne and
AddTwoNumbers), and test them both using the previous part3.c
main function to
convince yourself that they are working correctly. You will
need to copy the lines that
tested + and ++ and use function calls to your own
implementation. This will allow you
to compare the results of your own functions directly to what
you got from the standard
versions and see how close they are. Print out the results from
both calculations to see
29. that they are identical.
Part 4 – “Hello World!” on the OLED
You are going to print “Hello, World!” to the OLED on your
UNO32 board. In order to do
this, you will need to add ascii.c/h, Oled.c/h, OledDriver.c/h to
your basic HelloWorld
program. In order to use the OLED display, you will need to
call the functions: OledInit(),
OledDrawString(), and OledUpdate(). Take a look at the Oled.h
comments to see how to
use these functions.
G
G
G
Required Files (Case sensitivity matters)
• part0.c
• part1.c
30. • part2.c
• part3.c (technically optional but nice to have)
• SimpleMath.c
• SimpleMath.h
• part4.c
Frequently Asked Questions:
I see Connection Failed. in the PICkit3 tab when trying to
program the ChipKIT.
Unplug the PICkit3 and plug it back in. Try to program or
debug again. A window will pop up
prompting you to reselect the PICkit3 device. If this doesn’t
work repeat a few more times. If
that fails, ask a TA/tutor.
I see The programmer could not be started: Could not connect to
tool hardware: PICkit3PlatformTool,
com.microchip.mplab.mdbcore.PICKit3Tool.PICkit3DbgToolMa
nager in the PICkit3 tab when trying
to program the ChipKIT.
Just disconnect and reconnect the USB cable for the PICkit3 and
try again.
31. How do I know which files to #include?
A source file (.c) should include it's complementary header file
(.h). The header file should
include anything that's required for it to compile. That is, any
types or enums that are used in
function declarations should be included in the header. Because
the source file includes the
header, anything included in the header is effectively already
included in the source file. If the
source file uses any outside functions or standard library
functions, the matching header files for
those need to be included as well. You should never include a .c
file, only a .h.
Steps should be:
1. Try to compile
2. If a function is not defined (causing an error) find the header
file that defines it and
include that header.
3. Repeat until there are no undefined functions.
My code doesn't compile!
32. If the error message says something about multiple definitions
of 'main' it's because you
included two files that have a main function in your project.
Each of the three parts of this lab
need to be in separate projects; part1.c part2.c and part3.c
cannot be in the same MPLAB X
project.
If the error message says something about expecting a character
or identifier it's probably
because of a syntax mistake in the code. You can click on errors
to go to where they appear in
the code. Keep in mind that for many syntax errors, the error
that MPLAB X tells you about may
have been caused by an earlier line, and that a single-character
mistake can create many errors.
Refer to the Compiler Errors document provided for some
assistance with the more common
compilation errors you will encounter..
I see Failed to get Device ID in the PICkit3 tab when trying to
program the ChipKIT.
Just disconnect and reconnect the USB cable for the PICkit3 and
try again.
33. part1.c
// **** Include libraries here ****
// Standard libraries
#include <stdio.h>
#include <stdlib.h>
//Class specific libraries
#include "BOARD.h"
// Microchip libraries
#include <xc.h>
// User libraries
int main(void)
{
34. BOARD_Init();
unsigned char vals[] = { rand(), rand(), rand(), rand(), rand()
};
int valsToBeSorted[] = {vals[0], vals[1], vals[2], vals[3],
vals[4]};
// Sort the array in place.
int i, j;
for (i = 0; i < 5; i++)
{
int aTemp = valsToBeSorted[i];
for (j = i - 1; j >= 0; j--) {
if (valsToBeSorted[j] <= aTemp)
break;
valsToBeSorted[j + 1] = valsToBeSorted[j];
}
valsToBeSorted [j+1] = aTemp;
}
35. // Print out the array
printf("[");
for (i=0;i<4;i++) {
printf("%d, ", valsToBeSorted[i]);
}
printf("%d]n", valsToBeSorted[i]);
/*
* Returning from main() is bad form in embedded
environments. So we
* sit and spin.
*/
while (1);
}
part2.c
// **** Include libraries here ****
// Standard libraries
#include <stdio.h>
36. //Class specific libraries
#include "BOARD.h"
// Microchip libraries
#include <xc.h>
// User libraries
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
BOARD_Init();
/****************************************************
***********************************************
* Your code goes in between this comment and the following
one with asterisks.
*****************************************************
38. #include <math.h>
//CMPE13 Support Library
#include "BOARD.h"
// Microchip libraries
#include <xc.h>
#include <plib.h>
// User libraries
// **** Set macros and preprocessor directives ****
// **** Define global, module-level, or external variables here
****
// **** Declare function prototypes ****
39. #define QX 1.5
#define QY 2.8
#define PX -2.3
#define PY 8.6
#define DX (QX-PX)
#define DY (QY-PY)
int main() {
BOARD_Init();
{
/******************************** Your custom code
goes below here *******************************/
double mathHypot=hypotf(DX,DY);
printf("Hypot returned %f and should return
%frn",mathHypot,6.9340);
40. double mathAtan2=atan2(QX,QY);
printf("Atan2 returned %f and should return
%frn",mathAtan2,.4918);
/****************************************************
*********************************************/
// You can never return from main() in an embedded
system (one that lacks an operating system).
// This will result in the processor restarting, which is
almost certainly not what you want!
while (1);
}
}
Ascii.h
#ifndef ASCII_H
41. #define ASCII_H
#include <stdint.h>
// Specify the height and width of the characters defined in this
library.
#define ASCII_FONT_HEIGHT 8
#define ASCII_FONT_WIDTH 6
/**
* Pack a font for most of the standard ASCII characters into a
byte array. Each character is stored
* as ASCII_FONT_WIDTH number of bytes which each byte
corresponding to a vertical line of 8 pixels
* on the display.
*
* Some extended ASCII characters are supported:
* 0xF8: Degree symbol
*
* Some custom characters have also been implemented in lieu
42. of some non-printing characters:
* 0x01: Top of oven, on
* 0x02: Top of oven, off
* 0x03: Bottom of oven, on
* 0x04: Bottom of oven, off
*/
extern const uint8_t ascii[256][ASCII_FONT_WIDTH];
#endif // ASCII_H
Ascii.c
#include "Ascii.h"
/*
* This file defines a bitmap font corresponding to the standard
ASCII character set (0-7F).
*/
const unsigned char ascii[256][6] =
{
// Non-printing characters 0x00 - 0x1F
43. {0,0,0,0,0,0},
{ // top of oven, on (0x01)
0b00000101,
0b11110011,
0b00000101,
0b11110011,
0b00000101,
0b11110011
},
{ // top of oven, off (0x02)
0b00000101,
0b00000011,
0b00000101,
0b00000011,
0b00000101,
0b00000011
},
{ // bottom of oven, on (0x03)
95. *****************************************************
*************************/
/**
* Function: BOARD_Init(void)
* @param None
* @return None
* @brief Initializes the board for 80MHz SYSCLK and 20MHz
PBCLK.
*/
void BOARD_Init() {
// Set the PB divider to its maximum before altering
SYSCLK, ensure that PB limits are observed
OSCSetPBDIV(OSC_PB_DIV_8);
// Configure the system for the specified 80MHz clock
// Changse the flash wait state, RAM wait state, and enable
prefetch cache
SYSTEMConfig(SYSTEM_CLOCK,
SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);
96. // Configure for performance at 80MHz
SYSTEMConfigPerformance(SYSTEM_CLOCK);
// Use POSC, XT with PLL, XT specified above in config
// PLL multiplier of 20
// PLL postdiv of 1
// FRC postdiv of 1, not using FRC so value is
inconsequential
OSCConfig(OSC_POSC_PLL, OSC_PLL_MULT_20,
OSC_PLL_POST_1, OSC_FRC_POST_1);
// Set PBCLK to 20MHz
OSCSetPBDIV(OSC_PB_DIV_4);
// Disable the secondary oscillator
mOSCDisableSOSC();
//seeds the random number generator with the time
char seed1[] = __TIME__;
97. unsigned int seed2 = (((unsigned int) (seed1[7] ^ seed1[2]))
<< 8) | ((unsigned int) (seed1[4] ^ seed1[6]));
srand(seed2);
//enables the interrupt system in the new style
//INTConfigureSystem(INT_SYSTEM_CONFIG_MULT_VECT
OR);
unsigned int val;
// set the CP0 cause IV bit high
asm volatile("mfc0 %0,$13" : "=r"(val));
val |= 0x00800000;
asm volatile("mtc0 %0,$13" : "+r"(val));
INTCONSET = _INTCON_MVEC_MASK;
//INTEnableInterrupts();
98. int status;
asm volatile("ei %0" : "=r"(status));
// Initialize for serial
SERIAL_Init();
}
/**
* Function: BOARD_End(void)
* @param None
* @return None
* @brief shuts down all peripherals except for serial and A/D.
Turns all pins
* into input
* @author Max Dunne, 2013.09.20 */
void BOARD_End() {
// set all interrupt enable flags to zero
IEC0 = 0;
IEC1 = 0;
99. //set all flags to zero
IFS0 = 0;
IFS1 = 0;
// disable timer interrupts, clear flags and turn off module
T1CON = 0;
T2CON = 0;
T3CON = 0;
T4CON = 0;
T5CON = 0;
// disable input capture interrupts, clear flags and turn off
module
IC1CONCLR = _IC1CON_ICM_MASK;
IC2CONCLR = _IC2CON_ICM_MASK;
IC3CONCLR = _IC3CON_ICM_MASK;
101. // disable external interrupts, clear flags and turn off module
// set all ports to be digital inputs
TurnPortToInput(TRISB);
TurnPortToInput(TRISC);
TurnPortToInput(TRISD);
TurnPortToInput(TRISE);
TurnPortToInput(TRISF);
TurnPortToInput(TRISG);
//Serial and A/D are left on for output and battery monitoring
respectively
}
/**
* Function: BOARD_GetPBClock(void)
* @param None
* @return
103. *************************/
/**
* @Function SERIAL_Init(void)
* @param none
* @return none
* @brief Initializes the UART subsystem to 115200 and sets
up the circular buffer
* @author Max Dunne, 2011.11.10 */
void SERIAL_Init(void) {
// we first clear the Configs Register to ensure a blank state
and peripheral is off.
U1MODE = 0;
U1STA = 0;
//UARTConfigure(UART1, 0x00);
//we then calculate the required frequency, note that this
comes from plib source to avoid rounding errors
106. * @return Returns the number of characters read into buffer
* @brief Overrides the built-in function called for scanf() to
ensure proper functionality
*/
#ifndef LAB10_READ_OVERWRITE
int read(int handle, void *buffer, unsigned int len) {
int i;
if (handle == 0) {
while (!U1STAbits.URXDA) {
if (U1STAbits.OERR) {
U1STAbits.OERR = 0;
}
continue;
}
i = 0;
while (U1STAbits.URXDA) {
108. int main(void) {
BOARD_Init();
printf("rnThis stub tests SERIAL Functionality with
scanf");
printf("rnIt will intake integers and divide by 2");
printf("rn Peripheral Clock: %d", BOARD_GetPBClock());
printf("rn Peripheral Clock: %drn",
BOARD_GetSysClock());
char trash;
int input;
while (1) {
scanf("%d%c", &input, &trash);
printf("rnEntered: %dt/2: %drn", input, input / 2);
}
while (1);
return 0;
}
#endif
109. BOARD.h
/*
* File: BOARD.h
* Author: Max Dunne
*
* Created on December 19, 2012, 2:08 PM
*/
#ifndef BOARD_H
#define BOARD_H
/****************************************************
***************************
* PUBLIC #INCLUDES
*
*****************************************************
*************************/
#include <GenericTypeDefs.h>
#include <stdint.h>
110. #include <xc.h>
/****************************************************
***************************
* PUBLIC #DEFINES
*
*****************************************************
*************************/
//suppresses various warnings that we don't need to worry about
for CMPE13
#ifndef _SUPPRESS_PLIB_WARNING
#define _SUPPRESS_PLIB_WARNING
#endif
#ifndef _DISABLE_OPENADC10_CONFIGPORT_WARNING
#define _DISABLE_OPENADC10_CONFIGPORT_WARNING
#endif
111. // Define some standard error codes.
enum {
SIZE_ERROR = -1,
STANDARD_ERROR,
SUCCESS
};
// Specify the default UART to use. UART1 is selected the
Uno32, as it's the one on the USB port.
#define UART_USED UART1
// Set the baud rate for use with the UART. This is chosen as it's
the default baud rate for Tera
// Term.
#define UART_BAUD_RATE 115200
/*
* Set some helper macros for interfacing with the switches
112. */
// Define macros for referring to the single-bit values of the
switches.
#define SW1 PORTDbits.RD8
#define SW2 PORTDbits.RD9
#define SW3 PORTDbits.RD10
#define SW4 PORTDbits.RD11
/**
* Provides a way to quickly get the status of all 4 switches as a
nibble, where a bit is 1 if
* the button is being pressed and 0 if it's not. The buttons are
ordered such that bit 3 is switch
* 4 and bit 0 is switch 1.
* @see enum ButtonStateFlags
*/
#define SWITCH_STATES() ((PORTD >> 8) & 0x0F)
/**
113. * The SwitchStateFlags enum provides a bitmask for use with
the SWITCH_STATES macro. By bitwise-
* ANDing any of these enum values with the return value from
SWITCH_STATES, the current state of
* the switches can be tested.
*
* For example:
*
* uint8_t switchesState = SWITCH_STATES();
* if (switchesState & SWITCH_STATE_SW3) {
* // Switch 3 is on.
* }
*
* @see SWITCH_STATES()
*/
enum SwitchStateFlags {
SWITCH_STATE_SW1 = 0x1,
SWITCH_STATE_SW2 = 0x2,
SWITCH_STATE_SW3 = 0x4,
114. SWITCH_STATE_SW4 = 0x8
};
/*
* Set some helper macros for interfacing with the buttons
*/
// Define macros for referring to the single-bit values of the
buttons.
#define BTN1 PORTFbits.RF1
#define BTN2 PORTDbits.RD5
#define BTN3 PORTDbits.RD6
#define BTN4 PORTDbits.RD7
/**
* Provides a way to quickly get the status of all 4 pushbuttons
in to 4-bits, where a bit is 1 if
* the button is being pressed and 0 if it's not. The buttons are
ordered such that bit 3 is button
115. * 4 and bit 0 is button 1.
* @see enum ButtonStateFlags
*/
#define BUTTON_STATES() (((PORTD >> 4) & 0x0E) |
((PORTF >> 1) & 0x01))
/**
* The ButtonStateFlags enum provides a bitmask for use with
the BUTTON_STATES macro. By bitwise-
* ANDing any of these enum values with the return value from
BUTTON_STATES, the current state of
* the buttons can be tested.
*
* For example:
*
* uint8_t buttonsState = BUTTON_STATES();
* if (buttonsState & BUTTON_STATE_3) {
* // Buttons 3 is pressed down.
* }
*
116. * @see BUTTON_STATES()
*/
enum ButtonStateFlags {
BUTTON_STATE_1 = 0x1,
BUTTON_STATE_2 = 0x2,
BUTTON_STATE_3 = 0x4,
BUTTON_STATE_4 = 0x8
};
/**
* Enter an infinite loop and flash one of the status LEDs. This
should be used when there is an
* unrecoverable error onboard, like when a subsystem fails to
initialize.
*/
#define FATAL_ERROR() do {
TRISFCLR = 1;
LATFCLR = 1;
while (1) {
117. unsigned long int i;
for (i = 0; i < 600000; ++i);
LATFINV = 1;
}
} while (0);
/****************************************************
***************************
* PUBLIC FUNCTIONS *
*****************************************************
*************************/
/**
* Function: BOARD_Init(void)
* @param None
* @return None
* @brief Set the clocks up for the board, initializes the serial
port, and turns
* on the A/D subsystem for battery monitoring
118. * @author Max Dunne, 2013.09.15 */
void BOARD_Init();
/**
* Function: BOARD_End(void)
* @param None
* @return None
* @brief shuts down all peripherals except for serial and A/D.
Turns all pins
* into input
* @author Max Dunne, 2013.09.20 */
void BOARD_End();
/**
* Function: BOARD_GetPBClock(void)
* @param None
* @return PB_CLOCK - speed the peripheral clock is running
in hertz
119. * @brief returns the speed of the peripheral clock. Nominally
at 20Mhz
* @author Max Dunne, 2013.09.01 */
unsigned int BOARD_GetPBClock();
/**
* Function: BOARD_GetSysClock(void)
* @param None
* @return SYS_CLOCK - speed the main clock is running at
*/
unsigned int BOARD_GetSysClock();
#endif /* BOARD_H */
Oled.h
#ifndef OLED_H
#define OLED_H
120. /**
* This file provides a complete interface for interacting with
the OLED on Digilent's I/O Shield.
* It works by storing a backend array of pixel data for storing
modifications and then flushing
* that to the screen to update it when OledUpdate() is called.
Since OledUpdate() is very slow,
* this allows for batching together a lot of drawing operations
before finally updating the screen
* at the end in one go.
*
* This OLED is a monochrome display, offering black and
white as your color options. These can be
* specified as arguments to OledDrawChar() and OledClear().
Note that this coloring can be inverted
* on the display itself by calling OledSetDisplayInverted().
This doesn't actually modify the data
* stored in the pixels, but merely switches what colors each bit
value represents.
*
* The OLED offers both a pixel interface and a text interface
for drawing. Individual pixels can be
121. * read and changed with the Oled*Pixel() functions.
*
* Higher-level text operations can be done through
OledDrawChar() and OledDrawString, with the
* latter function being the easier one to use. It allows for
writing text across all OLED_NUM_LINES
* lines on the display where each line can hold up to
OLED_CHARS_PER_LINE complete characters.
*
* The font (defined in Ascii.h) used for drawing characters is a
custom monospaced font. It
* provides glyphs for most of the basic ASCII character set, but
is incomplete. Additionally some
* non-printing characters have been repurposed for custom
characters for specific uses
* (@see Ascii.h).
*/
#include "Ascii.h"
#include "OledDriver.h"
122. #include "BOARD.h"
/**
* Define constants for available colors for the OLED: either
white or black.
*/
typedef enum {
OLED_COLOR_BLACK = 0,
OLED_COLOR_WHITE = 1
} OledColor;
// Define how many lines of text the display can show.
#define OLED_NUM_LINES
(OLED_DRIVER_PIXEL_ROWS / ASCII_FONT_HEIGHT)
// Define how many complete characters can be displayed on a
row of text.
#define OLED_CHARS_PER_LINE
(OLED_DRIVER_PIXEL_COLUMNS / ASCII_FONT_WIDTH)
123. /**
* Initializes the OLED, turns it on, and clears the screen.
*/
void OledInit(void);
/**
* Sets a specific pixel in the frame buffer, available colors are
black or white.
* @note OledUpdate() must be called before the OLED will
actually display these changes.
* @param x The X position (left is zero)
* @param y The Y position (top is zero)
* @param color OLED_COLOR_WHITE or
OLED_COLOR_BLACK
*/
void OledSetPixel(int x, int y, OledColor color);
/**
* Reads a pixel from the frame buffer.
* @param x The X position (left is zero)
124. * @param y The Y position (top is zero)
* @return OLED_COLOR_WHITE or OLED_COLOR_BLACK
*/
int OledGetPixel(int x, int y);
/**
* Draws the specified character at the specified position, using
Ascii.h as the font.
* @note OledUpdate() must be called before the OLED will
actually display these changes.
* @param x The x-position to use as the left-most value for the
character.
* @param y The y-position to use as the top-most value for the
character
* @param c The character to write. Uses the character array
defined in Ascii.h
* @return True if the write succeeded. Fails on invalid inputs.
*/
uint8_t OledDrawChar(int x, int y, char c);
125. /**
* Draws a string to the screen buffer, starting on the top line.
OLED_CHARS_PER_LINE characters fit
* on each of the OLED_NUM_LINES lines on the screen. A
newline in the string will start the
* subsequent characters on the next line, otherwise once a line
has run out of room no more
* characters will display on the screen. There is no other
special processing of the input string
* besides this newline functionality, for example backspace
characters just render as blank
* characters.
*
* For example, the following code example shows Hello World
I'm Working! on the OLED with each word
* on its own line:
* OledInit();
* OledDrawString("HellonWorldI'mnWorking!n");
* OledUpdate();
*
* @note OledUpdate() must be called before the OLED will
actually display these changes.
126. * @param string A null-terminated string to print.
*/
void OledDrawString(const char *string);
/**
* Writes the specified color pixels to the entire frame buffer.
* @note OledUpdate() must be called before the OLED will
actually display these changes.
* @param p The color to write all pixels in the OLED to.
*/
void OledClear(OledColor p);
/**
* Sets the display to display pixels the opposite color than what
was intended. This does not
* change the stored value for any pixel.
* @see OledSetDisplayNormal
*/
void OledSetDisplayInverted(void);
127. /**
* Displays all pixels as they are stored, where a 0 indicates
black and a 1 indicates white. This
* is the default setting for the OLED on startup. This undoes
`OledSetDisplayInverted()`.
* @see OledSetDisplayInverted
*/
void OledSetDisplayNormal(void);
/**
* Turns on the OLED display.
* @note This is not required as part of initialization, as
`OledInit()` already does this.
*/
void OledOn(void);
/**
* Turns off the OLED display.
128. * @note This is not required as part of initialization, as
`OledInit()` already does this.
*/
void OledOff(void);
/**
* Refreshes the OLED display to reflect any changes. Should
be called after any operation that
* changes the display: OledSetPixel(), OledDrawChar(),
OledDrawString(), and OledClear().
*
* This function is very slow and so shouldn't be called too
often or the OLED might look dim or
* even show no data at all. This is because it uses a blocking
SPI interface to push out the entire
* screen of pixel data every time it's called. Like I said, very
slow function!
*
* For example, the following code example shows Hello World
I'm Workin! on the OLED with each word
* on its own line:
* OledInit();
129. * OledDrawString("HellonWorldI'mnWorking!n");
* OledUpdate();
*/
void OledUpdate(void);
#endif
OledDriver.h
#ifndef OLED_DRIVER_H
#define OLED_DRIVER_H
// Include standard C libraries.
#include <stdint.h>
// Include Microchip C libraries.
#include <xc.h>
/**
* Configure the port and pins for each of the 4 control signals
used with the OLED:
130. * * F6: Controls the power to the controller logic. Active-low,
so a 0 powers it on.
* * F5: Controls the power to the OLED display. Active-low,
so a 0 powers it on.
* * F4: Sets the input mode of the controller logic. High
indicates incoming data is display
* data, while low indicates they're commands.
* * G9: Reset pin connected to the display controller. Active-
low, so a 0 holds the logic in
* reset.
*/
#define OLED_DRIVER_CNTLR_POWER_PORT IOPORT_F
#define OLED_DRIVER_CNTLR_POWER_BIT BIT_6
#define OLED_DRIVER_OLED_POWER_PORT IOPORT_F
#define OLED_DRIVER_OLED_POWER_BIT BIT_5
#define OLED_DRIVER_MODE_PORT IOPORT_F
#define OLED_DRIVER_MODE_BIT BIT_4
#define OLED_DRIVER_RESET_PORT IOPORT_G
#define OLED_DRIVER_RESET_BIT BIT_9
131. // Set the SPI channel to use to communicate with the OLED.
#define OLED_DRIVER_SPI_CHANNEL SPI_CHANNEL2
// The number of pixel columns in the OLED display.
#define OLED_DRIVER_PIXEL_COLUMNS
128
// The number of pixel rows in the OLED display.
#define OLED_DRIVER_PIXEL_ROWS
32
// Store how high each column is for the OLED in bits in terms
of data structure storage.
#define OLED_DRIVER_BUFFER_LINE_HEIGHT
8
// The number of bytes required to store all the data for the
whole display. 1 bit / pixel.
#define OLED_DRIVER_BUFFER_SIZE
((OLED_DRIVER_PIXEL_COLUMNS *
OLED_DRIVER_PIXEL_ROWS) / 8)
132. /**
* This array is the off-screen frame buffer used for rendering.
It isn't possible to read back from
* the OLED display device, so display data is rendered into this
off-screen buffer and then copied
* to the display. The high-order bits equate to the lower pixel
rows.
* @note Any time this is updated, An
`OledDriverUpdateDisplay()` call must be performed.
*/
extern uint8_t rgbOledBmp[OLED_DRIVER_BUFFER_SIZE];
/**
* Initialize the PIC32MX to communicate with the UG-
23832HSWEG04 OLED display through the SSD1306
* display controller.
*/
void OledHostInit(void);
/**
133. * Initialize the OLED display and driver circuitry.
*/
void OledDriverInitDisplay(void);
/**
* Disable the Oled display before power-off. This means
powering it up, sending the display off
* command, and finally disabling Vbat.
*/
void OledDriverDisableDisplay(void);
/**
* Update the display with the contents of rgb0ledBmp.
*/
void OledDriverUpdateDisplay(void);
/**
* Set the LCD to display pixel values as the opposite of how
they are actually stored in NVRAM. So
134. * pixels set to black (0) will display as white, and pixels set to
white (1) will display as black.
*/
void OledDriverSetDisplayInverted(void);
/**
* Set the LCD to display pixel values normally, where a 1
indicates white and a 0 indicates black.
* This is the default operating mode of the LCD and the mode
it starts up in.
*/
void OledDriverSetDisplayNormal(void);
#endif // OLED_DRIVER_H
Oled.c
#include <stddef.h>
#include "OledDriver.h"
#include "Oled.h"
135. #include "Ascii.h"
// in simulator we do nothing with the hardware, printing
instead
void OledInit(void)
{
#ifndef __MPLAB_DEBUGGER_SIMULATOR
// First initialize the PIC32 to be able to talk over SPI to the
OLED.
OledHostInit();
// Now send initialization commands to the OLED.
OledDriverInitDisplay();
// Clear the frame buffer by filling it with black pixels.
OledClear(OLED_COLOR_BLACK);
// Finally update the screen, triggering a write of all black
136. pixels to the screen.
OledUpdate();
#endif
}
void OledSetPixel(int x, int y, OledColor color)
{
#ifndef __MPLAB_DEBUGGER_SIMULATOR
// Check for valid inputs before doing anything.
if (x >= OLED_DRIVER_PIXEL_COLUMNS || y >=
OLED_DRIVER_PIXEL_ROWS || x < 0 || y < 0) {
return;
}
// Map the x/y coordinates into a byte/bit index.
unsigned int index = ((y & 0xFFF8) << 4) + x;
unsigned int shift = y & 0x0007;
// Now set the pixel to the proper color, doing nothing if an
137. invalid color was specified.
if (color == OLED_COLOR_WHITE) {
rgbOledBmp[index] = rgbOledBmp[index] | (1 << shift);
} else if (color == OLED_COLOR_BLACK) {
rgbOledBmp[index] = rgbOledBmp[index] & ~(1 << shift);
} else {
return;
}
#endif
}
int OledGetPixel(int x, int y)
{
#ifndef __MPLAB_DEBUGGER_SIMULATOR
// Check for valid inputs before doing anything.
if (x >= OLED_DRIVER_PIXEL_COLUMNS || y >=
OLED_DRIVER_PIXEL_ROWS || x < 0 || y < 0) {
return OLED_COLOR_BLACK;
}
138. // Map the x/y coordinates into a byte/bit index.
unsigned int index = ((y & 0xFFF8) << 4) + x;
unsigned int shift = y & 0x0007;
// Now return the desired bit.
return (rgbOledBmp[index] >> shift) & 0x01;
#else
return OLED_COLOR_BLACK;
#endif
}
//in simulator this is the same as putchar
uint8_t OledDrawChar(int x, int y, char c)
{
#ifndef __MPLAB_DEBUGGER_SIMULATOR
if (x <= OLED_DRIVER_PIXEL_COLUMNS -
139. ASCII_FONT_WIDTH && y <=
OLED_DRIVER_PIXEL_ROWS - ASCII_FONT_HEIGHT) {
// We need to convert our signed char into an unsigned
value to index into the ascii[] array.
int charIndex = (int) (unsigned char) c;
// Now first determine the columns and rows of the OLED
bits that need to be modified
int rowMin, rowMax, colMin, colMax;
rowMin = y / ASCII_FONT_HEIGHT;
int rowY = y % ASCII_FONT_HEIGHT;
rowMax = (y + ASCII_FONT_HEIGHT) /
OLED_DRIVER_BUFFER_LINE_HEIGHT;
colMin = x;
colMax = x + ASCII_FONT_WIDTH;
{
// Generate a positive mask for where in the column the
new symbol will be drawn.
int colMask = ((1 << ASCII_FONT_HEIGHT) - 1) <<
rowY;
int j;
140. for (j = 0; j < colMax - colMin; ++j) {
int oledCol = colMin + j;
uint8_t newCharCol = rgbOledBmp[rowMin *
OLED_DRIVER_PIXEL_COLUMNS + oledCol] & ~colMask;
// Make sure we always grab from the top part of the
character.
newCharCol |= (ascii[charIndex][j] & (colMask >>
rowY)) << rowY;
rgbOledBmp[rowMin *
OLED_DRIVER_PIXEL_COLUMNS + oledCol] = newCharCol;
}
}
if (rowMax > rowMin) {
// Generate a positive mask for where in the column the
new symbol will be drawn.
// Since we need the lower portion of the symbol, we
recalculate its height.
int colMask = ((1 << ASCII_FONT_HEIGHT) - 1) >>
(OLED_DRIVER_BUFFER_LINE_HEIGHT - rowY);
int j;
for (j = 0; j < colMax - colMin; ++j) {
int oledCol = colMin + j;
141. uint8_t newCharCol = rgbOledBmp[rowMax *
OLED_DRIVER_PIXEL_COLUMNS + oledCol] & ~colMask;
// Make sure we grab the proper part of the character
from the font.
newCharCol |= (ascii[charIndex][j] & (colMask <<
(OLED_DRIVER_BUFFER_LINE_HEIGHT - rowY))) >>
(OLED_DRIVER_BUFFER_LINE_HEIGHT -
rowY);
rgbOledBmp[rowMax *
OLED_DRIVER_PIXEL_COLUMNS + oledCol] = newCharCol;
}
}
}
#else
putchar(c);
#endif
return FALSE;
}
142. void OledDrawString(const char *string)
{
#ifndef __MPLAB_DEBUGGER_SIMULATOR
if (string == NULL) {
return;
}
// Track the current line number we're in on the OLED. Valid
values are [0, OLED_NUM_LINES).
int line = 0;
// Track the current character we're writing to the OLED.
Valid values are
// [0, OLED_CHARS_PER_LINE).
int column = 0;
// Run through all characters. The maximum length can be the
number of lines times the number
// of characters per line + three newlines.
int i;
143. for (i = 0; string[i] != '0' && i < (OLED_NUM_LINES *
OLED_CHARS_PER_LINE + 3); ++i) {
// Move the cursor to the next line if a newline character is
encountered. This allows for
// early line ending.
if (string[i] == 'n') {
++line;
column = 0;
continue;
} else {
// Reset to the start of the next line if we've hit the
character limit of this line
// without seeing a newline.
if (column == OLED_CHARS_PER_LINE) {
++line;
column = 0;
}
// Now if we're < OLED_NUM_LINES and <
OLED_CHARS_PER_LINE we can proceed. The second
144. // check is implicitly handled by the above if-statement
that forces a newline after
// encountering a full line of characters.
if (line == OLED_NUM_LINES) {
break;
}
// Finally at this point, we can write characters to the
OLED.
OledDrawChar(column * ASCII_FONT_WIDTH, line *
ASCII_FONT_HEIGHT, string[i]);
++column;
}
}
#else
printf("%s",string);
#endif
}
145. void OledClear(OledColor p)
{
int i;
for (i = 0; i < OLED_DRIVER_BUFFER_SIZE; i++) {
if (p == OLED_COLOR_WHITE) {
rgbOledBmp[i] = 0xFF;
} else {
rgbOledBmp[i] = 0;
}
}
}
void OledSetDisplayInverted(void)
{
#ifndef __MPLAB_DEBUGGER_SIMULATOR
OledDriverSetDisplayInverted();
#endif
}
148. #include "OledDriver.h"
#define SPI_CHANNEL SPI_CHANNEL2
/**
* Constants for the various command values that can be sent to
the OLED driver.
*/
typedef enum {
OLED_COMMAND_SET_DISPLAY_LOWER_COLUMN_0
= 0x00,
OLED_COMMAND_SET_DISPLAY_UPPER_COLUMN_0 =
0x10,
OLED_COMMAND_SET_PAGE = 0x22,
OLED_COMMAND_SET_CHARGE_PUMP = 0x8D,
OLED_COMMAND_SET_SEGMENT_REMAP = 0xA1,
OLED_COMMAND_DISPLAY_NORMAL = 0xA6,
OLED_COMMAND_DISPLAY_INVERTED = 0xA7,
149. OLED_COMMAND_DISPLAY_OFF = 0xAE,
OLED_COMMAND_DISPLAY_ON = 0xAF,
OLED_COMMAND_SET_PRECHARGE_PERIOD = 0xD9,
OLED_COMMAND_SET_COM_PINS_CONFIG = 0xDA
} OledCommand;
/**
* Store constants for all settings used with the OLED driver.
*/
typedef enum {
OLED_SETTING_ENABLE_CHARGE_PUMP = 0x14,
OLED_SETTING_MAXIMUM_PRECHARGE = 0xF1,
OLED_SETTING_SEQUENTIAL_COM_NON_INTERLEAVED
= 0x20,
OLED_SETTING_REVERSE_ROW_ORDERING = 0xC8
} OledSetting;
#define OLED_DRIVER_PAGES 4
150. /**
* This array is the off-screen frame buffer used for rendering.
* It isn't possible to read back from the OLED display device,
* so display data is rendered into this off-screen buffer and
then
* copied to the display.
* @note Any time this is updated, An
`OledDriverUpdateDisplay()` call must be performed.
*/
uint8_t rgbOledBmp[OLED_DRIVER_BUFFER_SIZE];
// Function prototypes for internal-use functions.
void _OledPutBuffer(int size, uint8_t *buffer);
uint8_t _Spi2Put(uint8_t bVal);
void _DelayMs(unsigned int msec);
/**
* Initialize the PIC32MX to communicate with the UG-
23832HSWEG04 OLED display through the SSD1306
151. * display controller.
*/
void OledHostInit(void)
{
// Open SPI2 as a master in 1-byte mode running at 10MHz.
// The peripheral bus is running at 10Mhz, and we want a
10MHz SPI bus clock.
int pbClkDiv = 20000000 / 10000000;
SpiChnOpen(SPI_CHANNEL2, SPI_OPEN_MSTEN |
SPI_OPEN_CKP_HIGH | SPI_OPEN_MODE8, pbClkDiv);
// Set RF4-6 as digital outputs for controlling data/command
selection, logic power, and display
// power. They're all initialized high beforehand, because that
disables power.
PORTSetBits(IOPORT_F,
OLED_DRIVER_CNTLR_POWER_BIT |
OLED_DRIVER_OLED_POWER_BIT |
OLED_DRIVER_MODE_BIT);
PORTSetPinsDigitalOut(OLED_DRIVER_MODE_PORT,
OLED_DRIVER_MODE_BIT); // RF4 sets whether the next SPI
byte is a data or command byte.
152. PORTSetPinsDigitalOut(OLED_DRIVER_CNTLR_POWER_PO
RT, OLED_DRIVER_CNTLR_POWER_BIT); // RF5 controls
power to the SSD1306 display controller.
PORTSetPinsDigitalOut(OLED_DRIVER_OLED_POWER_POR
T, OLED_DRIVER_OLED_POWER_BIT); // RF6 controls
power to the UG-23832HSWEG04 OLED display.
// Set RG9 as a digital output, tied to the reset pin on the
SG1306 controller, low => reset.
PORTSetBits(OLED_DRIVER_RESET_PORT,
OLED_DRIVER_RESET_BIT);
PORTSetPinsDigitalOut(OLED_DRIVER_RESET_PORT,
OLED_DRIVER_RESET_BIT);
}
/**
* Initialize the OLED display and driver circuitry.
*/
void OledDriverInitDisplay(void)
{
// Set the OLED into command mode.
153. PORTClearBits(OLED_DRIVER_MODE_PORT,
OLED_DRIVER_MODE_BIT);
// Power on the display logic, waiting 1ms for it to start up.
PORTClearBits(OLED_DRIVER_CNTLR_POWER_PORT,
OLED_DRIVER_CNTLR_POWER_BIT);
_DelayMs(1);
// Turn off the display.
_Spi2Put(OLED_COMMAND_DISPLAY_OFF);
// Toggle the reset pin.
PORTClearBits(OLED_DRIVER_RESET_PORT,
OLED_DRIVER_RESET_BIT);
_DelayMs(1);
PORTSetBits(OLED_DRIVER_RESET_PORT,
OLED_DRIVER_RESET_BIT);
// Enable the charge pump and
_Spi2Put(OLED_COMMAND_SET_CHARGE_PUMP);
154. _Spi2Put(OLED_SETTING_ENABLE_CHARGE_PUMP);
_Spi2Put(OLED_COMMAND_SET_PRECHARGE_PERIOD);
_Spi2Put(OLED_SETTING_MAXIMUM_PRECHARGE);
// Power on the display, giving it 100ms to start up.
PORTClearBits(OLED_DRIVER_OLED_POWER_PORT,
OLED_DRIVER_OLED_POWER_BIT);
_DelayMs(100);
// Invert row numbering so that (0,0) is upper-right.
_Spi2Put(OLED_COMMAND_SET_SEGMENT_REMAP);
_Spi2Put(OLED_SETTING_REVERSE_ROW_ORDERING);
// Set sequential COM configuration with non-interleaved
memory.
_Spi2Put(OLED_COMMAND_SET_COM_PINS_CONFIG);
_Spi2Put(OLED_SETTING_SEQUENTIAL_COM_NON_INTER
LEAVED);
155. // And turn on the display.
_Spi2Put(OLED_COMMAND_DISPLAY_ON);
}
/**
* Set the LCD to display pixel values as the opposite of how
they are actually stored in NVRAM. So
* pixels set to black (0) will display as white, and pixels set to
white (1) will display as black.
*/
void OledDriverSetDisplayInverted(void)
{
// Set the OLED into command mode.
PORTClearBits(OLED_DRIVER_MODE_PORT,
OLED_DRIVER_MODE_BIT);
_Spi2Put(OLED_COMMAND_DISPLAY_INVERTED);
}
156. /**
* Set the LCD to display pixel values normally, where a 1
indicates white and a 0 indicates black.
* This is the default operating mode of the LCD and the mode
it starts up in.
*/
void OledDriverSetDisplayNormal(void)
{
// Set the OLED into command mode.
PORTClearBits(OLED_DRIVER_MODE_PORT,
OLED_DRIVER_MODE_BIT);
_Spi2Put(OLED_COMMAND_DISPLAY_NORMAL);
}
/**
* Disable the Oled display before power-off. This means
powering it up, sending the display off
* command, and finally disabling Vbat.
*/
157. void OledDriverDisableDisplay(void)
{
// Set the OLED into command mode.
PORTClearBits(OLED_DRIVER_MODE_PORT,
OLED_DRIVER_MODE_BIT);
// Power on the OLED display logic, waiting for 1ms for it to
start up.
PORTClearBits(OLED_DRIVER_CNTLR_POWER_PORT,
OLED_DRIVER_CNTLR_POWER_BIT);
_DelayMs(1);
// Send the display off command.
_Spi2Put(OLED_COMMAND_DISPLAY_OFF);
// And finally power off the display, giving it 100ms to do so.
PORTSetBits(OLED_DRIVER_OLED_POWER_PORT,
OLED_DRIVER_OLED_POWER_BIT);
_DelayMs(100);
}
158. /**
* Update the display with the contents of rgb0ledBmp.
*/
void OledDriverUpdateDisplay(void)
{
uint8_t *pb = rgbOledBmp;
int page;
for (page = 0; page < OLED_DRIVER_PAGES; page++) {
// Set the LCD into command mode.
PORTClearBits(OLED_DRIVER_MODE_PORT,
OLED_DRIVER_MODE_BIT);
// Set the desired page.
_Spi2Put(OLED_COMMAND_SET_PAGE);
_Spi2Put(page);
// Set the starting column back to the origin.
160. * @param buffer The start of the uint8_t array to write.
*/
void _OledPutBuffer(int size, uint8_t *buffer)
{
uint8_t bTmp = 0;
int i = bTmp;//non ideal way of forcing Wall error to go away
for (i = 0; i < size; ++i) {
// Make sure the transmitter is ready
while (SPI2STATbits.SPITBE == 0);
// Then transmit the desired uint8_t.
SPI2BUF = *buffer++;
// And wait for a response. It's ignored, but we read it out
of the buffer anyways to keep
// the buffer clear.
while (SPI2STATbits.SPIRBF == 0);
bTmp = SPI2BUF;
161. }
}
/**
* Performs a blocking write of a single uint8_t over SPI2. The
response uint8_t is returned.
* @param bVal The uint8_t to write over SPI.
* @return The response to the transmission.
*/
uint8_t _Spi2Put(uint8_t bVal)
{
// Make sure the transmitter is ready
while (SPI2STATbits.SPITBE == 0);
// Then transmit the desired uint8_t.
SPI2BUF = bVal;
// And wait for a response.
while (SPI2STATbits.SPIRBF == 0);
162. // Before returning it.
uint8_t bRx = SPI2BUF;
return bRx;
}
/**
* Block the processor for the desired number of milliseconds.
* @note Assumes processor frequency of 80Mhz.
* @param msec The number of milliseconds to block for.
*/
void _DelayMs(uint32_t msec)
{
uint32_t tWait, tStart;
// Calculate the amount of wait time in terms of core
processor frequency.
tWait = (80000000L / 2000) * msec;
163. tStart = ReadCoreTimer();
while ((ReadCoreTimer() - tStart) < tWait); // wait for the
time to pass
}
ACC206 Final Paper Description: The ABC Company - DUE
Week 5
Writing the Final Paper
1. Must be 5 to 7 double-spaced pages of content, formatted
according to APA style – and remember your source citations!
2. Must include a title page with the following:
a. Title of paper
b. Student’s name
c. Course name and number
d. Instructor’s name
e. Date submitted
3. Must begin with an introductory paragraph that has a
succinct thesis statement.
4. Must address the topic of the paper with critical thought.
5. Must end with a conclusion that reaffirms your thesis.
6. Must document at least three, but no more than five sources
in APA style.
7. Must include a separate reference page, formatted
according to APA style.
Focus of the Final Paper
You’ve just been hired onto ABC Company as the corporate
controller. ABC Company is a manufacturing firm that
specializes in making cedar roofing and siding shingles. The
company currently has annual sales of around $1.2 million, a
164. 25% increase from the previous year. The company has an
aggressive growth target of reaching $3 million annual sales
within the next 3 years. The CEO has been trying to find
additional products that can leverage the current ABC employee
skillset as well as the manufacturing facilities.
As the controller of ABC Company, the CEO has come to you
with a new opportunity that he’s been working on. The CEO
would like to use the some of the shingle scrap materials to
build cedar dollhouses. While this new product line would add
additional raw materials and be more time-intensive to
manufacture than the cedar shingles, this new product line will
be able to leverage ABC’s existing manufacturing facilities as
well as the current staff. Although this product line will require
added expenses, it will provide additional revenue and gross
profit to help reach the growth targets. The CEO is relying on
you to help decide how this project can be afforded. Provide
details about the estimated product costs, what is needed to
break even on the project, and what level of return this product
is expected to provide.
In order to help out the CEO, you need to prepare a 5- to 7-page
report that will contain the following information (including
exhibits, but excluding your references and title page). Refer to
the accompanying Excel spreadsheet (available through your
online course) for some specific cost and profit information to
complete the calculations.
Final Paper SpreadsheetGet it from Week 5 FP description
I. An overall risk profile of the company based on current
economic and industry issues that it may be facing.
II. Current company cash flow
a. You need to complete a cash flow statement for the company
using the direct method.
165. b. Once you’ve completed the cash flow statement, answer the
following questions:
i. What does this statement of cash flow tell you about the
sources and uses of the company funds?
ii. Is there anything ABC Company can do to improve the cash
flow?
iii. Can this project be financed with current cash flow from the
company? Why or why not?
iv. If the company needs additional financing beyond what ABC
Company can provide internally (either now or sometime
throughout the life of the project), how would you suggest the
company obtain the additional financing, equity or corporate
debt, and why?
III. Product cost: ABC Company believes that it has an
additional 5,000 machine hours available in the current facility
before it would need to expand. ABC Company uses machine
hours to allocate the fixed factory overhead, and units sold to
allocate the fixed sales expenses. Bases on current research,
ABC Company expects that it will take twice as long to produce
the expansion product as it currently takes to produce its
existing product.
a. What is the product cost for the expansion product under
absorption and variable costing?
b. By adding this new expansion product, it helps to absorb the
fixed factory and sales expenses. How much cheaper does this
expansion make the existing product?
c. Assuming ABC Company wants a 40% gross margin for the
new product, what selling price should it set for the expansion
product?
d. Assuming the same sales mix of these two products, what are
the contribution margins and break-even points by product?
IV. Potential investments to accelerate profit: ABC company
has the option to purchase additional equipment that will cost
166. about $42,000, and this new equipment will produce the
following savings in factory overhead costs over the next five
years:
Year 1, $15,000
Year 2, $13,000
Year 3, $10,000
Year 4, $10,000
Year 5, $6,000
ABC Company uses the NPV method to analyze investments and
desires a minimum rate of return of 12% on the equipment.
a. What is the NPV of the proposed investment (ignore income
taxes and depreciation)?
b. Assuming a 5-year straight-line depreciation, how will this
impact the factory’s fixed costs for each of the 5 years (and the
implied product costs)? What about cash flow?
c. Considering the cash flow impact of the equipment as well as
the time-value of money, would you recommend that ABC
Company purchases the equipment? Why or why not?
V. Conclusion:
a. What are the major risk factors that you see in this project?
b. As the controller and a management accountant, what is your
responsibility to this project?
c. What do you recommend the CEO do?
Grading: Total Possible Score: 27.00
1.Develops an Overall Risk Profile Total: 4.00
Distinguished - Develops a thorough overall risk profile of the
company based on current economic and industry issues the
firm may be facing.
Proficient - Develops an overall risk profile of the company
167. based on current economic and industry issues the firm may be
facing. Minor details are missing.
Basic - Somewhat develops an overall risk profile of the
company based on current economic and industry issues the
firm may be facing. Relevant details are missing.
Below Expectations - Minimally develops an overall risk profile
of the company based on current economic and industry issues
the firm may be facing. Significant details are missing.
Non-Performance - The overall risk profile is either nonexistent
or lacks the components described in the assignment
instructions.
2.Current Company Cash Flow Total: 5.00
Distinguished - Creates a complete and accurate cash flow
statement using the direct method. Correctly interprets and
communicates the information calculated including a well-
supported recommendation to obtain additional financing.
Proficient - Creates a mostly accurate cash flow statement using
the direct method. Interprets and communicates the information
calculated including a recommendation to obtain additional
financing. Work contains minor inaccuracies.
Basic - Creates a partially accurate cash flow statement using
the direct method. Somewhat interprets and communicates the
information calculated including a limited recommendation to
obtain additional financing. Work contains several inaccuracies.
Below Expectations - Attempts to create a cash flow statement
using the direct method, interpret and communicate the
information calculated, and offer recommendations; however,
there are many inaccuracies in the cash flow statement and
interpretation, and the recommendation is incomplete.
168. Non-Performance - The current company cash flow is either
nonexistent or lacks the components described in the assignment
instructions.
3.Product Cost Total: 5.00
Distinguished - Correctly calculates the product cost, selling
price, contribution margin, and break-even point for the new
product. Correctly interprets the change in fixed cost and sales
expenses allocated to the original products with the introduction
of the new product. Provides complete supporting calculations
for each question.
Proficient - Correctly calculates, with minor errors, the product
cost, selling price, contribution margin and break-even point for
the new product. Correctly interprets, with minor exceptions,
the change in fixed cost and sales expenses allocated to the
original products with the introduction of the new product.
Provides supporting calculations for each question.
Basic - Calculates, with several errors, the product cost, selling
price, contribution margin, and break-even point for the new
product. Interprets, with several exceptions, the change in fixed
cost and sales expenses allocated to the original products with
the introduction of the new product. Provides some supporting
calculations for most questions.
Below Expectations - Calculations for the product cost, selling
price, contribution margin, and break-even point for the new
product are mostly incorrect. Interpretation of the change in
fixed cost and sales expenses allocated to the original products
with the introduction of the new product is incomplete.
Supporting calculations were not provided.
Non-Performance - The product cost is either nonexistent or
169. lacks the components described in the assignment instructions.
4.Potential Investments to Accelerate Profit Total: 4.00
Distinguished - Accurately calculates the net present value of
the investment, impact of depreciation on fixed costs, and cash
flow. Provides complete supporting calculations.
Recommendations are thorough, logical, and include a well-
supported rationale.
Proficient - Calculates the net present value of the investment,
impact of depreciation on fixed costs, and cash flow. Provides
mostly accurate supporting calculations. Recommendations are
logical and include a rationale, but minor details are missing.
Basic - Calculates the net present value of the investment,
impact of depreciation on fixed costs, and cash flow. Provides
some supporting calculations which contain several errors.
Recommendations and rationale are included, but relevant
details are missing.
Below Expectations - Calculates the net present value of the
investment, impact of depreciation on fixed costs, and cash
flow. Provides minimal supporting calculations which contain
many errors. No recommendations are included.
Non-Performance - The potential investments to accelerate
profit are either nonexistent or lack the components described in
the assignment instructions.
5.Conclusion Total: 4.00
Distinguished - Conclusion thoroughly covers the major risks
associated with the project and the controller’s responsibility to
the project. Provides a well-supported recommendation to the
CEO.
170. Proficient - Conclusion covers the major risks associated with
the project and the controller’s responsibility to the project.
Provides a recommendation to the CEO. Minor details are
missing.
Basic - Conclusion briefly covers the major risks associated
with the project and the controller’s responsibility to the
project; provides a recommendation to the CEO. Several details
are missing.
Below Expectations - Conclusion attempts to cover the major
risks associated with the project, the controller’s responsibility
to the project, and provide a recommendation to the CEO;
however, significant details are missing.
Non-Performance - The conclusion is either nonexistent or lacks
the required components.
Quantitative Literacy: Calculation Total: 1.00
Distinguished - Calculations are essentially all successful and
adequately all inclusive. Calculations are presented clearly and
succinctly.
Proficient - Calculations are mostly successful; adequately
comprehensive to solve the problem.
Basic - Attempted calculation either unsuccessfully or
represents only a segment of the calculations required to
comprehensively solve the problem.
Below Expectations - Attempted calculations both
unsuccessfully and is not comprehensive.
Non-Performance - The assignment is either nonexistent or
171. lacks the required components.
Critical Thinking: Explanation of Issues Total: 1.30
Distinguished - Clearly and comprehensively explains in detail
the issue to be considered, delivering all relevant information
necessary for a full understanding.
Proficient - Clearly explains in detail the issue to be considered,
delivering enough relevant information for an adequate
understanding.
Basic - Recognizes the issue to be considered, delivering
minimal information for understanding.
Below Expectations - Briefly recognizes the issue to be
considered, but may not deliver additional information
necessary for a basic understanding.
Non-Performance - The assignment is either nonexistent or
lacks the required components.
Written Communication: Control of Syntax and Mechanics
Total: 0.68
Distinguished - Displays meticulous comprehension and
organization of syntax and mechanics, such as spelling and
grammar. Written work contains no errors, and is very easy to
understand.
Proficient - Displays comprehension and organization of syntax
and mechanics, such as spelling and grammar. Written work
contains only a few minor errors, and is mostly easy to
understand.
Basic - Displays basic comprehension of syntax and mechanics,
such as spelling and grammar. Written work contains a few
172. errors, which may slightly distract the reader.
Below Expectations - Fails to display basic comprehension of
syntax or mechanics, such as spelling and grammar. Written
work contains major errors, which distract the reader.
Non-Performance - The assignment is either nonexistent or
lacks the required components.
Written Communication: APA Formatting Total: 0.68
Distinguished - Accurately uses APA formatting consistently
throughout the paper, title page, and reference page.
Proficient - Exhibits APA formatting throughout the paper.
However, layout contains a few minor errors.
Basic - Exhibits basic knowledge of APA formatting throughout
the paper. However, layout does not meet all APA requirements.
Below Expectations - Fails to exhibit basic knowledge of APA
formatting. There are frequent errors, making the layout
difficult to distinguish as APA.
Non-Performance - The assignment is either nonexistent or
lacks the components described in the instructions.
Written Communication: Page Requirement Total: 0.67
Distinguished - The paper meets the specific page requirement
stipulated in the assignment description.
Proficient - The paper closely meets the page requirement
stipulated in the assignment description.
Basic - The paper meets over half of the page requirement
173. stipulated in the assignment description.
Below Expectations - A fraction of the page requirement is
completed.
Non-Performance - The assignment is either nonexistent or
lacks the components described in the instructions.
Written Communication: Source Requirement Total: 0.67
Distinguished - Uses more than the required number of
scholarly sources, providing compelling evidence to support
ideas. All sources on the reference page are used and cited
correctly within the body of the assignment.
Proficient - Uses required number of scholarly sources to
support ideas. All sources on the reference page are used and
cited correctly within the body of the assignment.
Basic - Uses less than the required number of sources to support
ideas. Some sources may not be scholarly. Most sources on the
reference page are used within the body of the assignment.
Citations may not be formatted correctly.
Below Expectations - Uses inadequate number of sources that
provide little or no support for ideas. Sources used may not be
scholarly. Most sources on the reference page are not used
within the body of the assignment. Citations are not formatted
correctly.
Non-Performance - The assignment is either nonexistent or
lacks the components described in the instructions.