Homework 2 - Embedded programming and memory
Due 09/24/21 at 11am
Instructions
Submit these in slide format (ppt, pptx, or pdf) with each section on a different slide. Please do not put your name on the PDF, so that we can anonymize grading in Canvas. Number the questions/question parts. Questions in blue are optional/questions for you to think about to yourself.
You are graded on good-faith effort, not correctness. This means that you should attempt to answer every question, and if you did not reach an answer, you should describe your process and where you got stuck.
Embedded processors
Read the following parts of Lee/Seshia Chapter 8: Introduction, 8.1.1, 8.2 including inset on fixed-point (examples 8.6 and 8.7 optional)
If you have any questions about the reading, post them on Ed
(4 pts) Answer chapter 8, exercise 1
(4 pts) Answer chapter 8, exercise 3
Memory architectures
Read the following parts of Lee/Seshia Chapter 9: Introduction, 9.1, 9.2 up to “Direct-mapped caches) (p. 249), 9.3
If you have any questions about the reading, post them on Ed
(7 pts) Answer chapter 9, exercise 3
(4 pts) Answer chapter 9, exercise 4
Technical manual reading and assembly
Because instruction sets, architectures, memory layouts, and hardware components/configurations differ across MCUs, reading technical manuals is a skill in embedded systems. In this section, you will practice reading a description of the instruction set architecture of the CPU that is on your Arduino. In the pre-lab, you will get more practice interpreting a datasheet.
The MCU on your Arduino is a SAM D21 Family chip. The CPU on board is an Arm Cortex-M0+ CPU. The architecture of the CPU is described in the Generic User Guide.
(8 pts) Based on the descriptions in Chapter 3 (note on terminology: “immediate” value is a constant numerical value), what does the following assembly code do?
LDR R0, [R7] MOV R1, #0 MOV R2, #0 a: SUBS R3, R1, R0 BMI b ADD R2, R2, R1 ADD R1, R1, #1 B a b: STR R2, [R6]
Hint 1: 3.3.6 may help you decipher the BMI instruction
Hint 2: write a comment that explains every line. For example,
MOV R1, #0 // R1 = 0
. In the manual, pay attention to what the operands mean. Remember to check if optional operands were used. Then, sketch a flow chart that explains the logic (you do not have to show this flowchart in your final submission, but it might help explain your reasoning if you don’t reach a final answer). Finally, summarize in words what the code does.
Breadth of embedded architectures
Pick an MCU from this list of common microcontrollers. Answer the following (remember cite any sources used):
(1 pt) What word size does the architecture of the chip use?
(1 pt) What is the name of the assembly language the chip uses?
(1 pt) What on chip memory does the chip have?
(1 pt) What peripherals does it offer?
(2 pts) Is the chip still in production? If not, can you identify the last year of production? If so, what is the approximate current cost to buy the chip?
We will compare and contrast our findings in class, which will be the participation grade of the homework (5 pts).