Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
61 views
Homework 2 FIVER
Tarea de fiver
Uploaded by
RonyVargas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as DOCX, PDF or read online on Scribd
Download now
Download
Save Homework 2 FIVER For Later
Download
Save
Save Homework 2 FIVER For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
61 views
Homework 2 FIVER
Tarea de fiver
Uploaded by
RonyVargas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as DOCX, PDF or read online on Scribd
Download now
Download
Save Homework 2 FIVER For Later
Carousel Previous
Carousel Next
Save
Save Homework 2 FIVER For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 4
Search
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
Homework 2
PDF
No ratings yet
Homework 2
4 pages
Part b Practice Programs v1
PDF
No ratings yet
Part b Practice Programs v1
13 pages
MC LABMANUAL
PDF
No ratings yet
MC LABMANUAL
17 pages
CP Assignment Rakshit
PDF
No ratings yet
CP Assignment Rakshit
31 pages
COMP1
PDF
No ratings yet
COMP1
6 pages
C Assignment
PDF
No ratings yet
C Assignment
5 pages
Binsys Technologies PVT - LTD
PDF
No ratings yet
Binsys Technologies PVT - LTD
18 pages
C Programs Assignment 1
PDF
No ratings yet
C Programs Assignment 1
16 pages
Write A C Program That Receives 10 Float Numbers From The Console and Sort Them in Nonascending Order, and Prints The Result
PDF
No ratings yet
Write A C Program That Receives 10 Float Numbers From The Console and Sort Them in Nonascending Order, and Prints The Result
36 pages
Jntu C Lab Programs
PDF
No ratings yet
Jntu C Lab Programs
66 pages
PPSL MANUAL student copy (1)
PDF
No ratings yet
PPSL MANUAL student copy (1)
140 pages
Test-1 Key 2
PDF
No ratings yet
Test-1 Key 2
12 pages
C Assignments PDF
PDF
100% (2)
C Assignments PDF
9 pages
CS 11 - Exam 1 - Answer Key PDF
PDF
No ratings yet
CS 11 - Exam 1 - Answer Key PDF
5 pages
Assignment 1 - C
PDF
No ratings yet
Assignment 1 - C
4 pages
AdvC DA Mod PDF
PDF
No ratings yet
AdvC DA Mod PDF
37 pages
CP .Practical New
PDF
No ratings yet
CP .Practical New
29 pages
Ib - Tech - Computer Programming Lab
PDF
No ratings yet
Ib - Tech - Computer Programming Lab
22 pages
C Programming Lab Manual
PDF
100% (3)
C Programming Lab Manual
45 pages
TCS Impor
PDF
No ratings yet
TCS Impor
104 pages
Program Reasoning Lab Manual Part1
PDF
No ratings yet
Program Reasoning Lab Manual Part1
11 pages
090_Prem_Joshi
PDF
No ratings yet
090_Prem_Joshi
9 pages
15CSE102 Computer Programming: Answer All Questions
PDF
No ratings yet
15CSE102 Computer Programming: Answer All Questions
5 pages
c programming basic
PDF
No ratings yet
c programming basic
20 pages
EE110: Programming For Engineers - 1: Sections A, B, C (Fall 2011)
PDF
No ratings yet
EE110: Programming For Engineers - 1: Sections A, B, C (Fall 2011)
6 pages
C QUE & SOL (1)
PDF
No ratings yet
C QUE & SOL (1)
40 pages
Top 30 C Programs Asked in Interview
PDF
No ratings yet
Top 30 C Programs Asked in Interview
30 pages
DAC / Wimc Stage - II Sample Question: Page 1 of 3
PDF
No ratings yet
DAC / Wimc Stage - II Sample Question: Page 1 of 3
4 pages
Winsem2023-24 Bece320e Eth VL2023240505346 Cat-2-Qp - Key
PDF
No ratings yet
Winsem2023-24 Bece320e Eth VL2023240505346 Cat-2-Qp - Key
4 pages
Programs
PDF
No ratings yet
Programs
36 pages
Ds Lab
PDF
No ratings yet
Ds Lab
12 pages
CSE1111 Mid 233
PDF
No ratings yet
CSE1111 Mid 233
2 pages
QB ans (1)
PDF
No ratings yet
QB ans (1)
50 pages
cse115-lab-manual-12-function
PDF
No ratings yet
cse115-lab-manual-12-function
10 pages
C LAB Manual
PDF
No ratings yet
C LAB Manual
8 pages
PPS Lab Manual
PDF
No ratings yet
PPS Lab Manual
62 pages
ESC 101: Fundamentals of Computing Name Roll No Dept. Section
PDF
No ratings yet
ESC 101: Fundamentals of Computing Name Roll No Dept. Section
8 pages
Final CPL 18CPL17 LAB PROGRAMS Updated
PDF
No ratings yet
Final CPL 18CPL17 LAB PROGRAMS Updated
15 pages
Ibrahim Final Lab Report.1
PDF
No ratings yet
Ibrahim Final Lab Report.1
33 pages
C Progms List
PDF
No ratings yet
C Progms List
32 pages
Lab Assignment 221024
PDF
No ratings yet
Lab Assignment 221024
2 pages
105360 10 19UCSES301 B 3 12Unit 1 Solved Application Qns
PDF
No ratings yet
105360 10 19UCSES301 B 3 12Unit 1 Solved Application Qns
12 pages
t1 SDF Solutions
PDF
No ratings yet
t1 SDF Solutions
8 pages
CN Practical
PDF
No ratings yet
CN Practical
13 pages
C Programming Lab Programs
PDF
No ratings yet
C Programming Lab Programs
39 pages
Basic 10 C Programs
PDF
No ratings yet
Basic 10 C Programs
22 pages
CCN Lab Answer
PDF
No ratings yet
CCN Lab Answer
16 pages
Jalpaiguri Reserch Paper
PDF
No ratings yet
Jalpaiguri Reserch Paper
2 pages
Fall12exam Final KAIST
PDF
No ratings yet
Fall12exam Final KAIST
11 pages
Clang Mat
PDF
No ratings yet
Clang Mat
72 pages
Cse 1071 2023 12 06
PDF
No ratings yet
Cse 1071 2023 12 06
2 pages
C Cat1&2
PDF
No ratings yet
C Cat1&2
4 pages
112
PDF
No ratings yet
112
13 pages
ESC135_SESSION-1_to_10 (1)
PDF
No ratings yet
ESC135_SESSION-1_to_10 (1)
32 pages
523 00490 0 W27C257
PDF
No ratings yet
523 00490 0 W27C257
14 pages
Free RTOS
PDF
No ratings yet
Free RTOS
50 pages
Ascensores
PDF
No ratings yet
Ascensores
2 pages
Integrador PWM
PDF
No ratings yet
Integrador PWM
1 page
Tiva Programa Con Teclado
PDF
No ratings yet
Tiva Programa Con Teclado
3 pages
Keil-uVision4Tutorial-Creating C Project
PDF
No ratings yet
Keil-uVision4Tutorial-Creating C Project
16 pages
Teclado Matricial 4X3 Keypad PDF
PDF
No ratings yet
Teclado Matricial 4X3 Keypad PDF
2 pages
Project of TIVA
PDF
No ratings yet
Project of TIVA
1 page
NIE2206 Laboratory Notes Part 2 (Spring Term 2018/19)
PDF
No ratings yet
NIE2206 Laboratory Notes Part 2 (Spring Term 2018/19)
42 pages
SD Card
PDF
No ratings yet
SD Card
3 pages
Interrupcions: Processor - I/O Speed Mismatch
PDF
No ratings yet
Interrupcions: Processor - I/O Speed Mismatch
18 pages
EGR 2201 Lab 10 Transient Analysis in Multisim: Objectives
PDF
No ratings yet
EGR 2201 Lab 10 Transient Analysis in Multisim: Objectives
3 pages
Stefan-Boltzmann Law: 2 H C Exp 1
PDF
No ratings yet
Stefan-Boltzmann Law: 2 H C Exp 1
16 pages