EEET2481 Tutorial2 Accompanying Slides - 2024C
EEET2481 Tutorial2 Accompanying Slides - 2024C
EEET2481
Embedded Systems
Design and
Implementation
Tutorial 2 – Accompany Slides
1
RMIT Classification: Trusted
1. Check attendance
22
RMIT Classification: Trusted
Previous Lecture
• We discussed:
33
RMIT Classification: Trusted
Warm-up
• Configure the PLL register to have the input frequency from HXT (12 MHz) as a
clock source to generate and provide a 50 MHz clock signal via PLL core.
44
RMIT Classification: Trusted
Warm-up
IN_DV =1
IN_DV = 0b1
55
RMIT Classification: Trusted
Warm-up
NF 1
𝐹 𝑂𝑈𝑇 =F 𝐼𝑁 . .
𝑁𝑅 𝑁𝑂
FB_DV = 48
IN_DV = 0b11_0000
66
RMIT Classification: Trusted
Next...
77
RMIT Classification: Trusted
—
Review - Bit Manipulation for
Masking
8
RMIT Classification: Trusted
99
RMIT Classification: Trusted
10
10
RMIT Classification: Trusted
Step 1a & 1b
(0b1111<<0)
-> result in 1111_0000 (our mask)
Step 1c
A & (0b1111<<0)
1010_1111
&
1111_0000
Result:
1010_0000
11
11
RMIT Classification: Trusted
12 12
RMIT Classification: Trusted
13
13
RMIT Classification: Trusted
• Task 1 - Configure the NUC140 MCU to use HXT (12 MHz) as a clock source to
generate and provide a 50 MHz clock signal to the microprocessor core via PLL
core.
• Task 2 - In the main program, toggle a GPIO pin and then measure its blinking
frequency to validate the success of the clock configuration
14
14
RMIT Classification: Trusted
15
15
RMIT Classification: Trusted
Simplified Diagram
Example: configure the NUC140 MCU to use HXT (12 MHz) as a clock source to generate and provide a 50 MHz clock signal
to the microprocessor core.
• Input clock source is from HXT via PLLOUT
• Output clock is 50MHz
16
16
RMIT Classification: Trusted
17
17
RMIT Classification: Trusted
Step 1
18
RMIT Classification: Trusted
enabled:
a. PWRCON[0] is set to 1.
#define HXT_STATUS 1<<0
b. Wait for HXT to be stable before we
while(!(CLK->CLKSTATUS & HXT_STATUS));
can configure.
19
19
RMIT Classification: Trusted
Struct Pointer
20
20
RMIT Classification: Trusted
CLK_T Struct
21
21
RMIT Classification: Trusted
Struct Pointer
CLK->PWRCON |= 1<<0;
22
22
RMIT Classification: Trusted
for PLLOUT:
o PLLCON[19] is clear to 0
23
23
RMIT Classification: Trusted
a. PLLCON[16] is clear to 0.
24
24
RMIT Classification: Trusted
25
25
RMIT Classification: Trusted
• Step 1D
o PLLCON[8:0] is set to 48 (i.e.,
FB_DV=48NF=48+2=50)
o PLLCON[13:9] is set to 1 (i.e.,
IN_DV=1NR=1+2=3)
o PLLCON[15:14] is set to 3 (i.e.,
OUT_DV=0b11NO=4)
• PLLCON[15:0] is set to
0b1100_0010_0011_0000 or 0xC230
26
26
RMIT Classification: Trusted
27
27
RMIT Classification: Trusted
28
28
RMIT Classification: Trusted
Step 2
29
RMIT Classification: Trusted
30
30
RMIT Classification: Trusted
31
31
RMIT Classification: Trusted
32
32
RMIT Classification: Trusted
33
33
RMIT Classification: Trusted
Full Program
Upload on Canvas
34
34
RMIT Classification: Trusted
35
RMIT Classification: Trusted
Be discussed in Tutorial 3
36
36
RMIT Classification: Trusted
Measurement
37
37
RMIT Classification: Trusted
Review Questions
38
RMIT Classification: Trusted
Tutorial Question 1
• Question 1: With the current clock configuration code, what is the clock source
and clock frequency of the MCU according to the Manual?
39
39
RMIT Classification: Trusted
Tutorial Question 2
• Question 2: What is the output signal frequency generated at GPIO port C pin
12 (i.e., the LED5’s flashing frequency) from the measurement?
40
40
RMIT Classification: Trusted
Tutorial Question 3
• Question 3: Study the manual and lecture, then modify the current embedded
software program to decrease CPU clock frequency by 50% compared to the
existing code. Build and load the new program to the board. Then, confirm the
flashing frequency of the GPC12 (LED5). Explain your changes and include the
snapshot from the measurement equipment.
41
41
RMIT Classification: Trusted
Tutorial Question 4
• Question 4: Study the manual and lecture, then modify the current embedded
software program to change the MCU clock frequency to 36 MHz (PLL should
be used as the CPU’s clock source). Build and load the new program to the
board. Then, confirm the flashing frequency of the GPC12 (LED5). Explain your
changes and include the snapshot from the measurement equipment.
42
42
RMIT Classification: Trusted
43
43
RMIT Classification: Trusted
•IMPORTANT NOTES:
o Always include code to check status of those clock sources after
enabling them.
o There are several options to tweak clock frequency to our
application’s needs (via CLKDIV and PLLCON).
o If a register (or one bit or groups of bits of that register) is write-
protected, it needs to be unlocked (by your software program)
before being written to (and locked after the register access is
completed to avoid further unwanted changes to them).
44
44
RMIT Classification: Trusted
—
Thank you
45
RMIT Classification: Trusted
Note
46
46