Lab 8 & 9 PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Student Workbook EE-07310: Microprocessor based Embedded Systems

LABORATORY SESSION # 7
#Group Daniyal Intisar
Messam Raza
Maryam Ijaz
Daniyal Intisar
BSEE02163115
7 Hardware Delay Using STM32F100xx Timers

7.1 EQUIPMENT & MATERIAL REQUIRED

- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________

7.2 PRE-LAB PREPARATIONS

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

7.3 PROCEDURE

_____________________________________________________________________
_____________________________________________________________________

54
Student Workbook EE-07310: Microprocessor based Embedded Systems

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
7.4 OBSERVATION & RESULTS

- Complete ‘main.c’ code

55
Student Workbook EE-07310: Microprocessor based Embedded Systems

Figure 7.1: Complete code from Keil µVision

56
Student Workbook EE-07310: Microprocessor based Embedded Systems

- Successful creation of HEX file

Figure 7.2: 0 Errors, 0 Warnings

- Software screenshots in debugging session

(a) Timer 2 (b) GPIOA

57
Student Workbook EE-07310: Microprocessor based Embedded Systems

(c) GPIOC

Figure 7.3: (a) Timer2, (b) GPIOA and (c) GPIOC peripherals

- Hardware pictures

Figure 7.4: Hardware setup

58
Student Workbook EE-07310: Microprocessor based Embedded Systems

- Oscilloscope screenshot

Figure 7.4: Oscilloscope screenshot

7.5 LEARNING OUTCOMES

What do you learn from this lab?

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

7.6 EXERCISE QUESTIONS

- Evaluate value of TIMx_PSC for 100ms, 1s and 10s delay.

100ms:_______________________________________________________________
_____________________________________________________________________
1s:__________________________________________________________________
_____________________________________________________________________

59
Student Workbook EE-07310: Microprocessor based Embedded Systems

10s:_________________________________________________________________
_____________________________________________________________________

- Modify the program such that two LEDs (PC8 and PC9) toggles after pressing
the switch at 1Hz frequency

Figure 7.5: Modified code block

Figure 7.6: Oscilloscope screenshot of signals at PA0 and PC8

60
Student Workbook EE-07310: Microprocessor based Embedded Systems

Figure 7.7: Oscilloscope screenshot of signals at PA0 and PC9

- Point-out the changes in the code section to toggle the two LEDs alternatively.

Figure 7.8: Code section modified for blinking of LEDs alternatively

- Identify the hazards of using for loop instead of STM32F100xx timers

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

61
Student Workbook EE-07310: Microprocessor based Embedded Systems

GENERALIZED LAB RUBRICS


Component with Above Meeting Approaching Below Weight / Score
Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)

Is able to build a Is able to assemble a Is only able to Is not able to


given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components  50
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements

Recording Is able to record Is able to record Is only able to Is unable to


Measurements accurate accurate record accurate record accurate

(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions

Is able to Is able to Is not able to Is unable to


formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data

Design / Is able to design / Is able to design / Is able to Is unable to


Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem

Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features

Is able to Is able to complete a Is able to Is unable to


efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /
 50
(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

62
Student Workbook EE-07310: Microprocessor based Embedded Systems

LABORATORY SESSION # 8
#Group Daniyal Intisar
Messam Raza
Maryam Ijaz
Daniyal Intisar
BSEE02163115

8 PWM Generation using STM32F100xx Timer

8.1 EQUIPMENT & MATERIAL REQUIRED

- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________
- __________________________________

8.2 PRE-LAB PREPARATIONS

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

8.3 PROCEDURE

63
Student Workbook EE-07310: Microprocessor based Embedded Systems

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

8.4 OBSERVATION & RESULTS


-Complete code

64
Student Workbook EE-07310: Microprocessor based Embedded Systems

Main.c:-

65
Student Workbook EE-07310: Microprocessor based Embedded Systems

Main.h:-

66
Student Workbook EE-07310: Microprocessor based Embedded Systems

67
Student Workbook EE-07310: Microprocessor based Embedded Systems

Pwm.h:-

Figure 8.1: Complete code from Keil µVision

68
Student Workbook EE-07310: Microprocessor based Embedded Systems

- Successful creation of HEX file

Figure 8.2: 0 Errors, 0 Warnings

- Software screenshots in debugging session

Figure 8.3: Debugger session

69
Student Workbook EE-07310: Microprocessor based Embedded Systems

- Hardware pictures

Figure 8.4: Hardware setup

- Oscilloscope screenshots

70
Student Workbook EE-07310: Microprocessor based Embedded Systems

Figure 8.5: Oscilloscope screenshot

8.5 LEARNING OUTCOMES

What do you learn from this lab?

_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________
_____________________________________________________________________

8.6 EXERCISE QUESTIONS

- Modify the program so that the value of TIMx_CCRx is assigned through


passing a variable in the function Duty_Cycle()[Hint: Modify the function
in ‘main.c’].

Figure 8.6: ‘main.c’ code

Figure 8.7: ‘pwm.c’ code

71
Student Workbook EE-07310: Microprocessor based Embedded Systems

Figure 8.8: ‘pwm.h’ code

- Generate PWM with different duty cycles (10%, 20%, 30% … 90%).

DC Code section modified Oscilloscope screenshot


10
%

20
%

72
Student Workbook EE-07310: Microprocessor based Embedded Systems

30
%

40
%

50
%

60
%

73
Student Workbook EE-07310: Microprocessor based Embedded Systems

70
%

80
%

90
%

Figure 8.9: PWM with different duty cycles

74
Student Workbook EE-07310: Microprocessor based Embedded Systems

- Re-write the program to generate a PWM with variable duty cycle, the duty
cycle automatically changes after a specific interval of time (say 3 sec).

main.c

main.h

Figure 8.10: Code block

Figure 8.11: Oscilloscope screenshot

75
Student Workbook EE-07310: Microprocessor based Embedded Systems

GENERALIZED LAB RUBRICS


Component with Above Meeting Approaching Below Weight / Score
Used
Taxonomy Expectation (4) Expectation (3) Expectation (2) Expectation (1) 100 (1–4)

Is able to build a Is able to assemble a Is only able to Is not able to


given setup neatly given setup using copy a given assemble a given
and timely using correct hardware setup using setup using
correct hardware components after correct hardware correct hardware
Building
components and / minor revisions components components  30
(Hardware) – P4
or can reorganize /
adapt to new /
special
requirements

Recording Is able to record Is able to record Is only able to Is unable to


Measurements accurate accurate record accurate record accurate
 20
(Hardware / measurements all measurements most measurements on measurements
Software) – C3 the time of the time some occasions

Is able to Is able to Is not able to Is unable to


formulate/develop evaluate/conclude evaluate/conclude comprehend
theories in correctly about correctly about investigation
addition to investigation investigation parameters
Investigation
evaluating/conclu parameters by parameters by
(Hardware / ☐
ding correctly assessing data assessing data
Software) – C5
about
investigation
parameters by
assessing data

Design / Is able to design / Is able to design / Is able to Is unable to


Development of develop the develop the solution partially design / partially design /
Solution solution of a given of a given problem develop the develop the ☐
(Hardware / problem and add solution of a solution of a
Software) – C6 features to it given problem given problem

Is adept in the use Is able to use the Is able to use the Is unable to use
of software tool software tool software tool but the software tool
Software Usage
and can access effectively by cannot access all ☐
(Software) – C3
advanced features accessing all the the required
required features features

Is able to Is able to complete a Is able to Is unable to


efficiently given task using partially partially
complete a given required complete a given complete a given
task using programming task task
Programming advanced language constructs
Language programming / methods /
 50
(Software) – C3– language commands
C6 constructs /
methods /
commands and/or
add features to the
original task

76

You might also like