Lab2_

docx

School

University of Kentucky *

*We aren’t endorsed by this school

Course

287

Subject

Electrical Engineering

Date

Apr 3, 2024

Type

docx

Pages

6

Uploaded by MagistrateOwlMaster1081

Report
Lab 2 Objectives The purpose of this lab was to gain further experience with the TI Tiva Launchpad board, Keil IDE as well as the ARM assembly language. The emphasis within the lab was to understand the debugger in Keil and how to use it to recognize and log data. Additionally, to write simple functions that could be validated through a blinking sequence on our launchpad. Materials 1. Tiva-C TM4C123G Launchpad 2. Keil µVision® IDE 3. Keil Stellaris ICDI and drivers 4. Windows, Mac or Linux Machine running Windows 5. CPE287F22Lab2Handout.pdf 6. CPE287Lab2F22.zip for the Keil program a. Main.s, operation.s, PortF.s, Startup.s 7. 9/13 Lecture 7 notes Experiment This experiment was designed to get the students associated with the KEIL IDE debugger and to perform operations to be verified by holding a button combination. For part 1 of this lab, instructions were written in assembly to perform operations For part 2 of the lab, we wrote various forms of LDR instructions and looked at the memory window to determine the value of R6 after using various forms of LDR. For part 3 of the lab, we wrote code to implement the arithmetic operation Z = (A>>3) | (B&55). This was tested by holding down SW1. For part 4 of
the lab, we computed a number to a specific power (ie: x^n). This required passing in two integers and multiplying them together (and adding it to the previous result) in order to determine x^n. This value was then placed back into R0 and was tested by holding down SW2. Result Figure 1: Result and Condition Flag State for Operations Figure 2: R6 value using each of the LDR forms For part 1 of this lab, instructions were written in assembly to perform operations (denoted in Figure 1) where the result was recorded for each operation as well as the condition flag corresponding to N (negative), C (carry), V (overflow), and Z (zero) in the PSR register. For part 2 of the lab, we saw the result of using various forms of LDR instructions by looking into the memory window to determine the value of R6 which can be seen in Figure 2.
As referenced above, for part 3 of the lab, we wrote code to implement the arithmetic operation Z = (A>>3) | (B&55). The result of this code (found at the bottom of the document) was the TIVA board blinking a blue LED whenever we held down the switch 1. For part 4 of the lab, we computed a number to a specific power (ie: x^n). The result of the program was a green LED blinking whenever switch 2 was held down. Conclusion For this lab, I learned how to use the debugger in KEIL and what the different symbols mean such as the red circle referring to a breakpoint and the yellow arrow pointing to the next instruction to be executed. I also learned how to monitor program elements and microcontroller resources. I now understand how to use the registers panel to note the value of a register as well as the call stack and memory window. Through part 1 and 3, I learned what condition codes mean (Z: zero, V: overflow, C: carry, N: negative) and how to perform arithmetic operations which helped me in part 4 to write a program that would perform a simple computation using flow control and math operations to compute the exponent x^n with 2 numbers. Additionally, through part 2, I learned about what the different LDR forms mean: LDR: load 32 bit from one register to another; LDRB: load 8-bit unsigned value from a register to another; LDRSB: load 8- bit signed; LDRH: Load 16-bit unsigned; LDRSH: load 32-bit signed. Code debug MOV R0, #0x00000006 MOV R1, #0xFFFFFFFB MOV R2, #0x7FFFFFFF
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
ADDS R3, R0, R1; R3 = R0 + R1 SUBS R3, R0, R0; ADDS R3, R0, R2; SUBS R3, R1, R2; ADDS R3, R2, R1; ; Below is where Part 2 of the code starts MOV R7, #0x20000000 ADD R7, #2 LDR R6, [R7] LDRH R6, [R7] LDRB R6, [R7] LDRSH R6, [R7] LDRSB R6,[R7] BX LR ;Returns to main function Figure 3: Part 1 & 2 of the Code ; Should return Z = (A >> 3)|(B & 55) ; Assume A and B are in R0 and R1, respectively ; The value of Z should be placed in R0 at the end Part3_Function
LSR R0, #3 AND R1, R1, #55 ORR R2, R0, R1 MOV R0, R2 BX LR Figure 4: Part 3 of the Code ; Should return x^n ; Follows AAPCS: Assume x is in R0, n is in R1 ; The result should be placed in R0 at the end Part4_Function CMP R1, #0 BEQ loopone MOV R3, R0 looped CMP R1, #1 BEQ loopend MUL R0, R0, R3 SUB R1, R1, #1 B looped
loopone MOV R0, #1 loopend BX LR ALIGN ; make sure the end of this section is aligned END ; end of file Figure 5: Part 4 of the Code
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help