Location via proxy:
[ UP ]
[Report a bug]
[Manage cookies]
No cookies
No scripts
No ads
No referrer
Show this form
Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Loading...
User Settings
close menu
Welcome to Scribd!
Upload
Read for free
FAQ and support
Language (EN)
Sign in
0 ratings
0% found this document useful (0 votes)
58 views
Homework 2 FIVER
Uploaded by
RonyVargas
Tarea de fiver
Copyright:
© All Rights Reserved
Available Formats
Download
as DOCX, PDF or read online from Scribd
Download
Save
Save Homework 2 FIVER For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Homework 2 FIVER
Uploaded by
RonyVargas
0 ratings
0% found this document useful (0 votes)
58 views
4 pages
Document Information
click to expand document information
Tarea de fiver
Copyright
© © All Rights Reserved
Available Formats
DOCX, PDF or read online from Scribd
Share this document
Share or Embed Document
Sharing Options
Share on Facebook, opens a new window
Facebook
Share on Twitter, opens a new window
Twitter
Share on LinkedIn, opens a new window
LinkedIn
Share with Email, opens mail client
Email
Copy link
Copy link
Did you find this document useful?
0%
0% found this document useful, Mark this document as useful
0%
0% found this document not useful, Mark this document as not useful
Is this content inappropriate?
Report
Tarea de fiver
Copyright:
© All Rights Reserved
Available Formats
Download
as DOCX, PDF or read online from Scribd
Download now
Download as docx or pdf
Save
Save Homework 2 FIVER For Later
0 ratings
0% found this document useful (0 votes)
58 views
4 pages
Homework 2 FIVER
Uploaded by
RonyVargas
Tarea de fiver
Copyright:
© All Rights Reserved
Available Formats
Download
as DOCX, PDF or read online from Scribd
Save
Save Homework 2 FIVER For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download as docx or pdf
Jump to Page
You are on page 1
of 4
Search inside document
Fullscreen
Instructions - General ‘There are 5 questions on this assignment. Answer all forful credit. Questons or their subparts are not necesseriy eaualy weighted + You may workin groups of two but you must formulate your own responses, answer or solutions foreach question or problem. Formulating one ansner or solution and copying from each oer is not permissible. + Provide rationale, explanation, tre of soliton o reasoning or your answers where applicable. Simply and magically providing responses or ansners for those questions or problems that equre reasoning may not receive any cect + Submission must be in hardcopy and delved by the student in person. Use blank nd eter size typing (printer) paper andin porta layout ‘You may use handwriting or word processor or combination for your submission. However, it must be organized, legible and presentable ‘Wie your fullname, rocket ID and your group member's name on the op right ofthe rst page of your submission. For ‘multiple sheets, staple them a the top left Instructions - Specific to this assignment + You must use Keilisin to develop code for embedded applications. lease not that a Kel C project template for programming questions inthis assignment is provided as a single compressed folder whichis named as “keProjectTemplateForn2" and posted wth the course Blackboard sit + For programming questions, you wil ned fo very the corectness of your code using the Keiluision debugger. ‘Accordingly, you are expected to capture snapshots (as screen captures) of relevant debug windons to demonstrate the correctness of your code during execution. Annotate your screen captures to explain es needed, which must be included in your submission ‘+ Capture end include in your submission the compilrlinker output window that shows that your code compiles and inks without error warnings for each programming queston. ‘Develop a flonchart and pseudocode for each programming question (except question 1) end include es part of your submission, + Provide the sourcecode in your submission wth proper indentation, label use, commenting and layout foreach ‘programming queston. + For programing tasks thats not fully functional, provide @ detailed explanation for whats functional. Questions: 1, Implement and test the following functionalities through C code fragments, a) Write a C eode fragment to check a bit value. Declare three character type variables eb, eh? ‘and mask with initial values of 0x34 and 0x20 for chl and mask, respectively. C code should set, character type variable ch2 to | ifthe bit 5 in mask is I otherwise 0. Note that bits ina byte are numbered from 0 (sb) to 7 (msb) b) Write a C code fragment to seta bit value, Declare two character type variables eh1 and mask ‘with initial value of 0x34 for ch. C code should set bit 7 in variable ch! to I using mask without changing any other bit values in ch.©) Write a C eode fragment to clear a bit value. Declare two character type variables ehI and mask ‘with initial value of 0x34 for chi. C code should clear bit 3 in variable ch to 0 using mask ‘without changing any other bit values in chi. 4) Write a C code fragment to toggle a bit value. Declare two character type variables ch and. ‘mask with intial value of Ox34 for ch1. C code should toggle bit 4 in variable ch! using mask ‘without changing any other bit values in chl. 2. Write a C program for an embedded application (which must have a dead’ forever loop) which computes factorial of number $ using a “for loop” structure. Your program should use a single ‘nain() funetion to implement the fanetionality, and stay inthe desl forever loop once computation is complete 3. Write a C program for an embedded application (using a dead forever loop) which determines the ‘maximum valued number in an array of numbers. Declare a global array with 10 elements of integer type, name it maxValueArray, and initialize the array to following values: -1, 5,3, 8, -10, 23,6, 5 10. Declare a global integer type variable “arraySize” and initialize it to 10. Implement the functionality within the main() function. Once the task of determining the maximum number is ‘completed, the main() should stay in a forever loop. 4, Develop the following template into an embedded C program. '* Global variables here - avoid declaring too many glabals unnecessarily as itis not considered a good programming practice. “ int creditRatingAlice = 750; {VO represents “defaulted” and 1 represents “pai” forthe payment history int monthiyPaymenthistoryAlve|24)={1.000000001.41414.101.114.404) void main (void) { | main), while looping endlessly, sets a global flag creditStatus to the value retumed by the function J) rewardsOrAlarm(), } 1" Function called when Alice makes a monthly payment or defaults on the monthly payment. * Retums nothing, updates global variable creditRatingAlice, *! void updateCreditRatingAlice (int opcode, /" Of default, 4 if paid *){ J each monthly payment increments rating by 10 points all the way up to 800 1 every default decrements rating by 10 points down to 700. } "Function that raises an alarm when Alice's rating is 700 for 2 consecutive months, * or rewards her if she has maintained a rating of 800 for 2 consecutive months. * Reads montlyPaymentHistoryAlice for input * Returns 0 if alarm, 1 if reward, */ Page 2 of 4int rewardsOrAlarm (){ | Read next value in monthlyPaymenthistoryAlice. Note that this function needs to keep track of the | last array element accessed so that when it reaches the last it can rewind tothe first in 2 round, |_robin fashion to read a value from the monthlyPaymentHistoryAlice array forever. I Pass the read value in monthlyPaymentHistoryAlice to function updateCreditRatingAlioe(int x) Return reward/alarm value, ' 5. One approach to functional debugging is to collect input and output data forthe software for typical input values. In particular we define a set of input values, tin the software, and record the output data ‘generated by the software, In this exercise we will test the software using input values from 0 to NI, where Vis 25. Consider the funetion s\n (n) to test. The elaim is that this funetion calculates the sum. ofthe numbers N down to 1. For example suum (5 is $+4#3+2+1 which equals 15. Furthermore, we ‘ill also test the hypothesis that the sum of '’ numbers can be expressed as the simple caleulation of (HD)2. ‘The test program will evaluate the fumetion sum (r.) and store the result in the array at sunBtof [1]. We need to define a sevond funetion fun (n) that simply caleulates (N(V*1))2. We have another array funBut that we will use to store the fist 25 calculations of this second funetion ‘We will check in the main program for equivalence of the two functions by comparing elements of cumBu£ to the elements of funBué, The main funetion should set a flag value based on the outcome of this comparison. Ina top-down approach, we place the main program on the top and the funetions after. In this example, ‘we will configure the system as bottom up by placing the functions first and the main program at the end, Notice that bottom up organization does not need prototypes for the functions. Following C program template with code fragments are given to help you get started: ‘define TRUE 1 ‘define FALSE 0 ‘define N25 Waray size ‘unsigned long sum(unsigned long n){ ‘unsigned long partial, count: ) ‘unsigned long fun(unsigned long n) )int main(voidy{ Unsigned long num: Unsigned long sumBuflN], funBufN}; 1! arrays to store computed values: int corectFlag, ) Write the C code with following functions: sum (), fun () and main () ina bottom-up layout in a single source code file as an embedded application. Note that function definitions precede the main function in a bottom-up layout and therefore not requiring fuction prototype declarations as given in the above template. ‘As a secondary method of verification for equivalence of two computations, use Keil'uVision to verily that um (1) and fun (2) finetions compute the same values by comparing values stored in the unBu and FunBut arrays using appropriate windows in the debugger.
You might also like
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
From Everand
The Subtle Art of Not Giving a F*ck: A Counterintuitive Approach to Living a Good Life
Mark Manson
Rating: 4 out of 5 stars
4/5 (6021)
Principles: Life and Work
From Everand
Principles: Life and Work
Ray Dalio
Rating: 4 out of 5 stars
4/5 (625)
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
From Everand
The Gifts of Imperfection: Let Go of Who You Think You're Supposed to Be and Embrace Who You Are
Brené Brown
Rating: 4 out of 5 stars
4/5 (1131)
Never Split the Difference: Negotiating As If Your Life Depended On It
From Everand
Never Split the Difference: Negotiating As If Your Life Depended On It
Chris Voss
Rating: 4.5 out of 5 stars
4.5/5 (909)
The Glass Castle: A Memoir
From Everand
The Glass Castle: A Memoir
Jeannette Walls
Rating: 4.5 out of 5 stars
4.5/5 (1741)
Sing, Unburied, Sing: A Novel
From Everand
Sing, Unburied, Sing: A Novel
Jesmyn Ward
Rating: 4 out of 5 stars
4/5 (1245)
Grit: The Power of Passion and Perseverance
From Everand
Grit: The Power of Passion and Perseverance
Angela Duckworth
Rating: 4 out of 5 stars
4/5 (628)
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
From Everand
Hidden Figures: The American Dream and the Untold Story of the Black Women Mathematicians Who Helped Win the Space Race
Margot Lee Shetterly
Rating: 4 out of 5 stars
4/5 (937)
The Perks of Being a Wallflower
From Everand
The Perks of Being a Wallflower
Stephen Chbosky
Rating: 4.5 out of 5 stars
4.5/5 (2121)
Shoe Dog: A Memoir by the Creator of Nike
From Everand
Shoe Dog: A Memoir by the Creator of Nike
Phil Knight
Rating: 4.5 out of 5 stars
4.5/5 (547)
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
From Everand
The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
Ben Horowitz
Rating: 4.5 out of 5 stars
4.5/5 (358)
Her Body and Other Parties: Stories
From Everand
Her Body and Other Parties: Stories
Carmen Maria Machado
Rating: 4 out of 5 stars
4/5 (831)
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
From Everand
Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
Ashlee Vance
Rating: 4.5 out of 5 stars
4.5/5 (479)
Bad Feminist: Essays
From Everand
Bad Feminist: Essays
Roxane Gay
Rating: 4 out of 5 stars
4/5 (1062)
The Emperor of All Maladies: A Biography of Cancer
From Everand
The Emperor of All Maladies: A Biography of Cancer
Siddhartha Mukherjee
Rating: 4.5 out of 5 stars
4.5/5 (275)
Steve Jobs
From Everand
Steve Jobs
Walter Isaacson
Rating: 4.5 out of 5 stars
4.5/5 (814)
Angela's Ashes: A Memoir
From Everand
Angela's Ashes: A Memoir
Frank McCourt
Rating: 4.5 out of 5 stars
4.5/5 (444)
The Little Book of Hygge: Danish Secrets to Happy Living
From Everand
The Little Book of Hygge: Danish Secrets to Happy Living
Meik Wiking
Rating: 3.5 out of 5 stars
3.5/5 (434)
The World Is Flat 3.0: A Brief History of the Twenty-first Century
From Everand
The World Is Flat 3.0: A Brief History of the Twenty-first Century
Thomas L. Friedman
Rating: 3.5 out of 5 stars
3.5/5 (2281)
The Outsider: A Novel
From Everand
The Outsider: A Novel
Stephen King
Rating: 4 out of 5 stars
4/5 (1954)
A Man Called Ove: A Novel
From Everand
A Man Called Ove: A Novel
Fredrik Backman
Rating: 4.5 out of 5 stars
4.5/5 (4952)
Brooklyn: A Novel
From Everand
Brooklyn: A Novel
Colm Tóibín
Rating: 3.5 out of 5 stars
3.5/5 (2029)
The Yellow House: A Memoir (2019 National Book Award Winner)
From Everand
The Yellow House: A Memoir (2019 National Book Award Winner)
Sarah M. Broom
Rating: 4 out of 5 stars
4/5 (99)
Yes Please
From Everand
Yes Please
Amy Poehler
Rating: 4 out of 5 stars
4/5 (1961)
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
From Everand
Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
Gilbert King
Rating: 4.5 out of 5 stars
4.5/5 (273)
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
From Everand
The Sympathizer: A Novel (Pulitzer Prize for Fiction)
Viet Thanh Nguyen
Rating: 4.5 out of 5 stars
4.5/5 (125)
The Art of Racing in the Rain: A Novel
From Everand
The Art of Racing in the Rain: A Novel
Garth Stein
Rating: 4 out of 5 stars
4/5 (4264)
A Tree Grows in Brooklyn
From Everand
A Tree Grows in Brooklyn
Betty Smith
Rating: 4.5 out of 5 stars
4.5/5 (1934)
The Woman in Cabin 10
From Everand
The Woman in Cabin 10
Ruth Ware
Rating: 3.5 out of 5 stars
3.5/5 (2599)
Team of Rivals: The Political Genius of Abraham Lincoln
From Everand
Team of Rivals: The Political Genius of Abraham Lincoln
Doris Kearns Goodwin
Rating: 4.5 out of 5 stars
4.5/5 (235)
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
From Everand
A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
Dave Eggers
Rating: 3.5 out of 5 stars
3.5/5 (233)
Wolf Hall: A Novel
From Everand
Wolf Hall: A Novel
Hilary Mantel
Rating: 4 out of 5 stars
4/5 (4059)
Fear: Trump in the White House
From Everand
Fear: Trump in the White House
Bob Woodward
Rating: 3.5 out of 5 stars
3.5/5 (805)
Homework 2
Document
4 pages
Homework 2
RonyVargas
No ratings yet
On Fire: The (Burning) Case for a Green New Deal
From Everand
On Fire: The (Burning) Case for a Green New Deal
Naomi Klein
Rating: 4 out of 5 stars
4/5 (75)
Rise of ISIS: A Threat We Can't Ignore
From Everand
Rise of ISIS: A Threat We Can't Ignore
Jay Sekulow
Rating: 3.5 out of 5 stars
3.5/5 (139)
Manhattan Beach: A Novel
From Everand
Manhattan Beach: A Novel
Jennifer Egan
Rating: 3.5 out of 5 stars
3.5/5 (883)
The Unwinding: An Inner History of the New America
From Everand
The Unwinding: An Inner History of the New America
George Packer
Rating: 4 out of 5 stars
4/5 (45)
John Adams
From Everand
John Adams
David McCullough
Rating: 4.5 out of 5 stars
4.5/5 (2520)
The Light Between Oceans: A Novel
From Everand
The Light Between Oceans: A Novel
M.L. Stedman
Rating: 4.5 out of 5 stars
4.5/5 (789)
The Constant Gardener: A Novel
From Everand
The Constant Gardener: A Novel
John le Carré
Rating: 3.5 out of 5 stars
3.5/5 (109)
523 00490 0 W27C257
Document
14 pages
523 00490 0 W27C257
RonyVargas
No ratings yet
Integrador PWM
Document
1 page
Integrador PWM
RonyVargas
No ratings yet
Ascensores
Document
2 pages
Ascensores
RonyVargas
No ratings yet
Keil-uVision4Tutorial-Creating C Project
Document
16 pages
Keil-uVision4Tutorial-Creating C Project
RonyVargas
No ratings yet
Free RTOS
Document
50 pages
Free RTOS
RonyVargas
No ratings yet
Tiva Programa Con Teclado
Document
3 pages
Tiva Programa Con Teclado
RonyVargas
No ratings yet
Teclado Matricial 4X3 Keypad PDF
Document
2 pages
Teclado Matricial 4X3 Keypad PDF
RonyVargas
No ratings yet
SD Card
Document
3 pages
SD Card
RonyVargas
No ratings yet
Project of TIVA
Document
1 page
Project of TIVA
RonyVargas
No ratings yet
NIE2206 Laboratory Notes Part 2 (Spring Term 2018/19)
Document
42 pages
NIE2206 Laboratory Notes Part 2 (Spring Term 2018/19)
RonyVargas
No ratings yet
Stefan-Boltzmann Law: 2 H C Exp 1
Document
16 pages
Stefan-Boltzmann Law: 2 H C Exp 1
RonyVargas
No ratings yet
EGR 2201 Lab 10 Transient Analysis in Multisim: Objectives
Document
3 pages
EGR 2201 Lab 10 Transient Analysis in Multisim: Objectives
RonyVargas
No ratings yet
Interrupcions: Processor - I/O Speed Mismatch
Document
18 pages
Interrupcions: Processor - I/O Speed Mismatch
RonyVargas
No ratings yet
Little Women
From Everand
Little Women
Louisa May Alcott
Rating: 4 out of 5 stars
4/5 (105)