1 of 16

EE 319K�Introduction to Embedded Systems

Lecture 10: Exam2

Lab 7

  1. Variables on stack with binding
  2. Modular code with both C and assembly (AAPCS)
  3. Busy-wait and blind synchronization
  4. Recursion
  5. Fixed point

Lab 8

  1. EE319K C, EE319H C++
  2. Sampling
  3. Calibration and measurements

Exam 2 and Quizzes 9,10

11-1

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

2 of 16

EE 319K�Introduction to Embedded Systems

Lecture 10: Exam2

Material

1) Book Chapters 1-7, ebook chapters 1-13,17

2) Labs 1-7

3) Lectures 1-9

4) Worksheet questions: 2.10, 4.1, 4.2, 4.3, 4.6, 5.1, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 7.3, 7.4, 8.17, 9.4, 9.5, 9.13, 9.14

See Class website for practice exams

11-2

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

3 of 16

Agenda

Exam 2

      • 30% assembly, 70% C
      • Parameter-passing
      • AAPCS
      • Pointers
      • Arrays
      • Strings
      • Structs
      • Linked structures

Not on Exam 2

      • FSMs
      • I/O (GPIO, SPI, ST7735 LCD, DAC)
      • SysTick
      • Circuits
      • Fixed-point
      • C++

11-3

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

4 of 16

Exam 2 process

Like Exam 1, Quiz 9 and Quiz 10

      • Download the project, unzip
      • Add your EID
      • Read the specific instructions for your version
      • Understand the questions
      • Observe the inputs
      • Understand the desired outputs
      • Edit/build/debug MANY times for looking at grader

Canvas quiz has a hard stop at 8:30

      • Stop coding at 8:25
      • Enter UART text (not image) into canvas
      • We will not take images, emails, or late submissions
      • Make sure you put something in the UART

Upload source code files by 8:40

      • Exam2ASMPart.s assembly file
      • Exam2CPart.c C file
      • Running these must match magic code (no more typing)

11-4

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

5 of 16

Exam 2 review

0) Being able to quickly design, implement, and debug software

1) Understanding differences between data and address, being able to use pointers and indices

2) Understanding differences between 8-bit, 16-bit data and 32-bit data

3) Understanding differences between signed and unsigned integers

4) Programming if-then if-then-else for-loops while-loops and do-while-loops in C/assembly

5) Processing a variable-length array or string, either size first or terminating code at end

6) Addition, subtraction, multiplication, division, shift, and, or, eor (signed and unsigned)

11-5

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

6 of 16

Exam 2 review

7) Structures

8) Call by value, call by reference, return by value

9) AAPCS Program conventions

    • Save and restore R4-R11,LR if you wish to modify
    • Parameter passing in registers R0,R1,R2,R3
    • Return parameter in R0
    • Push/Pop even number of registers
    • Balancing the stack
    • Your function may have to call other functions

10) Accessing arrays strings and structures

    • Arrays of characters, integers, structures
    • Variable size (termination, first element, another field)
    • Stepping through two or more arrays at a time
    • 8/16/32-bit data, signed/unsigned numbers
    • Pointer and index access to arrays, arrays of structures

11-6

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

7 of 16

Exam 2 review

  • A) You may be given one or more variable length arrays of data, buf[i]
    • The size may be the first entry
    • The size may be a separate parameter/field
    • There may be a termination code
    • The data may be 8-bit ASCII characters or integers
    • The integers may be 8 16 or 32 bits
    • Integers may be signed or unsigned
    • A pointer to this array may be passed in R0-R3
    • You may be asked to deal with special cases: size=0, size too big, overflow

11-7

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

8 of 16

Easy Array problems

  • Determine the size of the array
  • Return the first element of the array
  • Find the maximum or minimum element in an array
  • Find the sum of all the elements
  • Find the average of all the elements
  • Find the mode of all the elements
  • Find the range = maximum - minimum
  • Find the maximum or minimum slope (buf[i+1]-buf[i])
  • Find the maximum or minimum absolute value
  • Count the number of times a particular value occurs
  • Search for the occurrence of one string in another
  • Concatenate two strings together
  • Delete characters from a string
  • Insert one string into another
  • Move data from one place to another within an array or string

Your exam will be harder than these.

Solve the problem. Do not try and search for the answer

11-8

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

9 of 16

In class Problems

Assembly (20-30%)

  • Find the maximum in an array
    • 32 bit unsigned and 16 bit signed
  • Find the average of all the elements
    • 8-bit unsigned, 255 termination code

C (80-70%)

  • Search for the occurrence of char in string return position
  • Concatenate two strings together and put in third
  • Given an array of structs find min field(member)

Advice:

  • Watch for size and datatype
  • Address calculations
  • Call-by value vs. reference
  • Structs - declaration and access
  • Global vs parameter
  • Testcases - solve the problem being tested vs. what you think is being asked.

Don’t expect an Exam

pattern/template from previous years

11-9

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

10 of 16

Exam 2

  • Runs on your laptop
    • Keil5 in simulation (no board)
    • During exam: Keil, Keil help, PC calculator
    • Needs internet to download and upload
  • Written in mix of C and assembly
    • A routine you are asked to write debug could be in either C or assembly
  • Overall grade a combination of
    • Numerical score from grader
    • Program style (reviewed later if needed)
  • Tricking the grader is dishonest
    • Hard-coding answers is dishonest
    • Communicating with others during test

11-10

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

11 of 16

Common mistakes

  • Infer test by guessing
  • Trying to run out of the ZIP file
  • Uploading wrong .s .c files
  • Changing R4-R11 without push/pop
  • Big arrays on stack

  • Unknown size at declaration

  • Cannot change const input parameters

int function(int x){ int y[1000];

int size;

int x[size];

11-11

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

12 of 16

AAPCS or stack

  • Read/write permission fault
  • Infinite loop (grader stops or runs forever the same test cases over and over)
  • Score = 300

11-12

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

13 of 16

Advice

  • Observe test cases
  • Add global debugging variable, watch
  • How to create snapshots
  • Run a few old exams to install LM3S1968

During the exam we try to answer questions with “yes”, “no”, “won’t answer”

11-13

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

14 of 16

Summary

Grading based mostly on numerical results and some part of the grading will be based on programming style (needed to resolve inconsistencies). We consider it necessary to actually solve the problem. The autograder will lower your grade to 0 if you trick the grader into giving points (hard coding so it returns correct answers without actually calculating the output from the inputs).

 

Your laptop needs to be running Keil uVision 5 in simulation. You will use the internet to download the exam at the beginning, and then use the internet to upload the solution to canvas at the end. The instructions for your exam will be very similar to the practice exams.

11-14

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

15 of 16

Quiz 8 is Spring 2021 Exam 2

Directions�1) download the zip file containing the Exam Keil project. Link:

http://users.ece.utexas.edu/~valvano/Volume1/Exam2P/

user name:    OLED�password      1306

 

2) UNZIP the Exam2_S21.zip file ON THE DESKTOP�3) Open the Exam2_S21.uvprojx with uVision v5

4) Enter your EID in Exam2CPart.c

5) Build the project

6) Start the debugger

7) Run

8) Observe that the UART#1 window

shows a score.

11-15

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi

16 of 16

Old Exam 2

C/assembly exams (not all exams were the same length). �CExam2_StringCompare Easy practice Exam 2 involving ASCII strings�CExam2_CalculusSpring2013 Medium difficulty practice Exam 2 involving Math�CExam2_Merge Medium difficulty practice Exam 2 involving ASCII strings�CExam2_Unicode Practice Exam 2 involving 8 and 16-bit arrays�CExam2_PermuteCombine Medium difficulty practice Exam 2 involving Math�CExam2_Mode Practice Exam 2 involving arrays and structures�CExam2_DataBase Practice Exam 2 involving arrays and structures�CExam2_ManhattanDistance Exam 2 involving math and structures�CExam2_EKGprocess Medium difficulty�CExam2_HeartMonitor Medium difficulty�CExam2_StringConversions Extremely hard, string to octal

Assembly only exams�Exam2_Mode8 Hard practice Exam 2 involving strings and pointers �Exam2_ArrayOfStruct Exam 2 with structures and arrays of structures

http://users.ece.utexas.edu/~valvano/Volume1/exams.htm

11-16

Bard, Tiwari, Telang, Holt, Cuevas, Gerstlauer, Valvano, Yerraballi