0% found this document useful (0 votes)
77 views1 page

Cheat Sheet

Uploaded by

4hns6pms89
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, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views1 page

Cheat Sheet

Uploaded by

4hns6pms89
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, TXT or read online on Scribd

Practice Questions for Test-4:

1. Complete the following SysTick initialization assembly subroutine if you know SysTick will interrupt the processor every 25 ms, SysTick priority is 3, and the clock frequency is 80MHz.
SysTick_Init
; disable SysTick during setup
LDR R1, =0xE000E010
MOV R2, #0
STR R2, [R1]
; set the reload
LDR R1, =0xE000E014
LDR R0, =2000000
SUB R0, R0, #1
STR R0, [R1]
; clear the CURRENT register
LDR R1, =0xE000E018
STR R2, [R1]
; set NVIC system interrupt 15 to priority 3
LDR R1, =0xE000ED20
LDR R2, [R1]
AND R2, R2, #0x00FFFFFF
ORR R2, R2, #0x60000000
STR R2, [R1]
; enable SysTick with core clock
LDR R1, =0xE000E010
MOV R2, #7
STR R2, [R1]
BX LR
2. Complete the configuration of the following port E registers in this assembly code if you
know the processor executes Port E ISR whenever a positive logic switch connected to
PE3 is pressed. The priority of Port E is 4.
LDR R1, =GPIO_PORTE_IS_R ; Interrupt Sense register
LDR R0, [R1]
BIC R0, #0x08
STR R0, [R1]
LDR R1, =GPIO_PORTE_IBE_R ; Interrupt Both Edges
LDR R0, [R1]
BIC R0, #0x08
STR R0, [R1]
LDR R1, =GPIO_PORTE_IEV_R ; Interrupt Event
LDR R0, [R1]
ORR R0, #0x08
STR R0, [R1]
LDR R1, =GPIO_PORTE_ICR_R ; flag
MOV R0, #0x08
STR R0, [R1]
LDR R1, =GPIO_PORTE_IM_R ; Interrupt Mask Enable
LDR R0, [R1]
ORR R0, #0x08
STR R0, [R1]
LDR R1, =NVIC_PRI1_R ; Interrupt priority
LDR R0, [R1]
AND R0, #0xFFFFFF00
ORR R0, #0x00000080
STR R0, [R1]
LDR R1, =NVIC_EN0_R ; Interrupt enable register
LDR R0, =0x00000010
STR R0, [R1]

CPSIE I
BX LR
3. Which ISR will be executed by the processor if the Interrupt Program Status Register
IPSR=18
Note: 18 is the interrupt number, not the IRQ number.
Hint: to find the interrupt source, you need to use the formulas that’re used to find the
interrupt priority register from the interrupt IRQ number, and the interrupt priority
registers table below.

IRQ number n=18-16=2


m = n/4=0 à (NVIC_PRI0_R)
p = n%4=2
8*2+7=23
8*2+6=22
8*2+5=21
23-21 à (GPIO Port C)

Thus, the ISR that will be executed by the processor is (PORT C) ISR
4. For this question, change only the corresponding bits and keep all other bits of the
register at their original values.
a. Complete the following code that is used to select PD3 as the analog input channel of
ADC0
LDR R1, =ADC0_SSMUX3_R
LDR R0, [R1]
ADD your code here
AND R0, R0, #0xFFFFFFF0
ADD R0, R0, #4
STR R0, [R1]
b. Complete the following code that is used to make the maximum sampling rate of the
ADC 500K samples/second. Value is Bits 8 and 9 of SYSCTL_RCGC0_R
LDR R1, =SYSCTL_RCGC0_R
LDR R0, [R1]
ADD your code here
BIC R0, R0, #0x00000300
ORR R0, R0, #0x00000200
STR R0, [R1]
c. Complete the following code that is used to make the Timer as the trigger source of
ADC0. Value is Bits 15-12 of ADC0_EMUX_R
LDR R1, =ADC0_EMUX_R
LDR R0, [R1]
ADD your code here
BIC R0, R0, #0xF000
ORR R0, R0, #0x5000

STR R0, [R1]

You might also like