Ain Shams University
FACULTY OF ENGINEERING
CSE211s – Introduction to Embedded Systems
Assignment 2
Junior Computer and Systems Engineering — Section 3 — Spring 2024
Shams El-Din Mohamed Abdel-Monem 2101442
Submission Date : 19/05/2024
Contents
1 Assignment 1
1.1 Question . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
2
List of Tables
Listings
1
2
Problem Solution Question 1 . . . . . . . . . . . . . . . . . . . . .
Problem Solution Question 2 . . . . . . . . . . . . . . . . . . . . .
1
2
3
1
2
1
Assignment 1
1.1
Question
# include " tm4c123gh6pm . h "
# include " io . h "
3
4
void GPIO_Init ( void ) ;
5
void GPIOF_Handler () {
switch ( GP IO_POR TA_DAT A_R ) {
8
case 0:
9
GPI O_PORT A_DATA _R = 5;
10
break ;
11
case 5:
12
GPI O_PORT A_DATA _R = 6;
13
break ;
14
case 6:
15
GPI O_PORT A_DATA _R = 10;
16
break ;
17
case 10:
18
GPI O_PORT A_DATA _R = 9;
19
break ;
20
case 9:
21
GPI O_PORT A_DATA _R = 5;
22
break ;
23
}
6
7
24
GPIO_PORTF_ICR_R |= 0 x10 ;
25
26
}
27
28
29
int main () {
GPIO_Init () ;
30
GPIO_PORTF_IS_R = ~0 x11 ;
GPIO_PORTF_IBE_R = ~0 x11 ;
GPIO_PORTF_IEV_R &= ~ 0 x11 ;
GPIO_PORTF_IM_R = 0 x11 ;
NVIC_PRI7_R |= (1 < <22) ;
NVIC_EN0_R |= (1 < <30) ;
31
32
33
34
35
36
37
SysTick_Init () ;
38
39
GPI O_PORT F_DATA _R = 0;
40
41
__enable_irq () ;
42
43
while (1) {
}
44
45
46
}
47
48
49
void GPIO_Init () {
SYS CTL_RC GCGPIO _R |= 0 x20 ;
50
51
while (( SYSCTL_PRGPIO_R & 0 x20 ) ==0) ;
52
53
54
55
56
GPI O_PORT F_LOCK _R = GPIO_LOCK_KEY ;
GPIO_PORTF_CR_R |= 0 x1F ;
GPIO_PORTF_DEN_R |= 0 x1F ;
GPIO_PORTF_DIR_R |= 0 xE ;
2
GP IO _P OR TF _A FS EL _R = 0;
GP IO _P OR TF _A MS EL _R = 0;
GPI O_PORT F_PCTL _R = 0;
GPIO_PORTF_PUR_R = 0 x11 ;
57
58
59
60
61
}
Listing 1: Problem Solution Question 1
1
2
# include " tm4c123gh6pm . h "
# include " io . h "
3
4
5
void GPIO_Init ( void ) ;
void SysTick_Init ( void ) ;
6
void SysTick_Handler () {
switch ( GP IO_POR TA_DAT A_R ) {
9
case 0:
10
GPI O_PORT A_DATA _R = 5;
11
break ;
12
case 5:
13
GPI O_PORT A_DATA _R = 6;
14
break ;
15
case 6:
16
GPI O_PORT A_DATA _R = 10;
17
break ;
18
case 10:
19
GPI O_PORT A_DATA _R = 9;
20
break ;
21
case 9:
22
GPI O_PORT A_DATA _R = 5;
23
break ;
24
}
25 }
7
8
26
27
28
int main () {
GPIO_Init () ;
29
SysTick_Init () ;
30
31
GPI O_PORT F_DATA _R &= ~( RED | GREEN | BLUE ) ;
32
33
__enable_irq () ;
34
35
while (1) {
}
36
37
38
}
39
40
41
void GPIO_Init () {
SYS CTL_RC GCGPIO _R |= 0 x20 ;
42
while (( SYSCTL_PRGPIO_R & 0 x20 ) ==0) ;
43
44
GPI O_PORT F_LOCK _R = GPIO_LOCK_KEY ;
GPIO_PORTF_CR_R |= 0 x1F ;
GPIO_PORTF_DEN_R |= 0 x1F ;
GPIO_PORTF_DIR_R |= 0 xE ;
GP IO _P OR TF _A FS EL _R = 0;
GP IO _P OR TF _A MS EL _R = 0;
GPI O_PORT F_PCTL _R = 0;
GPIO_PORTF_PUR_R = 0 x11 ;
45
46
47
48
49
50
51
52
53
}
3
54
void SysTick_Init () {
NVIC_ST_CTRL_R = 0;
57
NVI C_ST_C URRENT _R = 0;
58
NVIC_ST_RELOAD_R = (160000000) / 20 - 1; // 200 * 6 = 1200 step
per minute = 20 steps per second
59
NVIC_ST_CTRL_R = 0 X07 ;
60
NVIC_SYS_PRI3_R = ( NVIC_SYS_PRI3_R &0 x00FFFFFF ) | 0 x20000000 ;
61 }
55
56
Listing 2: Problem Solution Question 2
4