Beruflich Dokumente
Kultur Dokumente
TM
External Use
Lab 4 Overview
Objective:
In this lab we will create a KDS Project with Processor Expert support and use the SDK for
peripheral drivers. We will add several components and import a source file with
implementation code.
Lab Flow:
Create
TM
External Use
Project Definition
Hardware: FRDM-K64F
Clock Configuration
Internal PLL; set to 120MHz
Bus Clock; 60MHz
Flash Clock: 20MHz
Pin Muxing
GPIO; UART
TM
External Use
Next up!
TM
External Use
4
TM
External Use
Click OK
TM
External Use
Enter Project4
Click Next
Select Device
1
TM
External Use
Select MK64FN1M0xxx12
Click Next
2
TM
External Use
Click Finish
Project View
Component Inspector
Editor View
Component View
Problem View
TM
External Use
Next up!
TM
External Use
Selecting Components
Components Needed:
Pin Muxing
TM
External Use
10
Component Inspector
1
Expand
Project4
2
Select the
Cpu
TM
External Use
11
TM
External Use
12
TM
External Use
13
Click
1 Scroll
Down
4
TM
External Use
14
Select
External reference clock
Enter 50 MHz
Select
MCG Settings
External Use
15
Scroll
Down
TM
External Use
16
Enter
120
Select
PEE
Enter 120
Enter 60
3
Enter 24
TM
External Use
17
Select:
pin_init:PinSettings
TM
External Use
18
1
2
TM
External Use
19
GPIO Switches
TM
External Use
20
Function Name
Direction
PTA4
SW3
Input
PTB21
LED_BLUE
Output
PTB22
LED_RED
Output
PTC6
SW2
Input
PTE26
LED_GREEN
Output
Function Name
Port Number
Direction
SW2
PTC6
Input
SW3
PTA4
Input
LED_BLUE
PTB21
Output
LED_GREEN
PTE26
Output
LED_RED
PTB22
Output
TM
External Use
21
Select
GPIO
TM
External Use
22
Click here
And
Select PTA4/
TM
External Use
23
TM
External Use
24
TM
External Use
25
Select Up
Select Enabled
Click Done
Enter Input
Enter SW3
TM
External Use
26
Click here
Select Output
Click here
Select PTB21/
2
1
TM
External Use
27
Enter LED_BLUE
TM
External Use
28
Click here
Select Output
Click here
Select PTB22/
2
1
TM
External Use
29
Enter LED_RED
TM
External Use
30
Click here
Select CMP0_IN0/
Click here
Select Input
TM
External Use
31
Enter SW2
TM
External Use
32
TM
External Use
33
Select Up
Select Enabled
Click Done
Click here
Select PTE26/
Click here
Select Output
TM
External Use
34
Enter LED_GREEN
Function Name
Direction
PTA4
SW3
Input
PTB21
LED_BLUE
Output
PTB22
LED_RED
Output
PTC6
SW2
Input
PTE26
LED_GREEN
Output
Function Name
Port Number
Direction
SW2
PTC6
Input
SW3
PTA4
Input
LED_BLUE
PTB21
Output
LED_GREEN
PTE26
Output
LED_RED
PTB22
Output
TM
External Use
35
Function
Port Number
Pin Number
Uart0 TX
PTB17
62
Uart0 RX
PTB16
63
TM
External Use
36
TM
External Use
37
Select UART
TM
External Use
38
1
Click on
Component Library
to bring up the library
3
Scroll down until you begin to see
fsl_xxx components
Click on
Alphabetical
TM
External Use
39
Selecting Components
Double Click on
fsl_gpio
Double Click on
fsl_pit
TM
External Use
40
Selecting Components
Scroll Down
Double Click on
fsl_uart
TM
External Use
41
Selecting Components
TM
External Use
42
Double-Click
gpio1:fsl_gpio
to bring up
Component
Inspector
TM
External Use
43
Enter
SW2
3
Notice how remaining fields
are filled in and problems
related to pin are resolved.
TM
External Use
44
3
Notice how remaining fields
are filled in and problems
related to pin are resolved.
TM
External Use
45
2
CAREFUL: Click +
Three Times on
Output pins number
for 4 input pins
TM
External Use
46
Scroll
Down
Select row
1
TM
External Use
47
Enter
LED_BLUE
TM
External Use
48
Enter
1
TM
External Use
49
Select row
2
Enter
LED_GREEN
1
TM
External Use
50
Select row
3
Enter
LED_RED
1
TM
External Use
51
TM
External Use
52
TM
External Use
53
Next up!
TM
External Use
54
In the Components View Click on the Generate Processor Expert Code Icon
TM
External Use
55
TM
External Use
56
Expand
Generated_Code
folder in the Project
Explorer
TM
External Use
57
main.c
enough said
Note: Go ahead and explore these files by double clicking on them and
use the Editor View to see how they are structured.
TM
External Use
58
Expand the
edit window up
TM
External Use
59
Open
Events.c
2
Scroll down to
here
TM
External Use
60
1
Expand
gpio1:fsl_gpio
3
4
External Use
61
Next up!
TM
External Use
62
Importing Files
TM
External Use
63
TM
External Use
64
TM
External Use
65
Click OK
TM
External Use
66
1
Double-Click
Lab4_main.c
and main.c
TM
External Use
67
Select main.c
for editing
TM
External Use
68
Clean
Build
TM
External Use
69
Next up!
Select Clean
TM
External Use
70
Click OK
TM
External Use
71
Clean complete
TM
External Use
72
1
Right Click
On
Project4
2
Select
Build Project
TM
External Use
73
TM
External Use
74
TM
External Use
75
Examine main.c
PEx
#includes here
main.c
Your declarations
here
Hardware initializations
Your code goes here
TM
External Use
76
Examine events.c
TM
External Use
77
Examine Lab4_main.c
TM
External Use
78
Examine Lab4_main.c
Main loop watch for switch presses
TM
External Use
79
Examine Lab4_main.c
Switch press
routines
Print routine
Delay loop
TM
External Use
80
Generate Code
Next up!
Setup
Debug Configuration
Download the code
Debug the code
TM
External Use
81
- OR 3b Option 2: Select:
Run Debug
Configurations
TM
External Use
82
External Use
83
TM
External Use
84
TM
External Use
85
Click Apply
Launching Debugger
1
NOTE: Next time, select from pull-down list on the Debug Icon
(ALWAYS SELECT FROM LIST)
TM
External Use
86
As the debugger starts up, you will see the following dialog:
TM
External Use
87
Generate Code
Next up!
TM
External Use
88
Debug View
Variable View Stack
Editor/Source View
Disassembly
View
Breakpoint
TM
External Use
89
Editor moves
to this line
TM
External Use
90
TM
External Use
91
TM
External Use
92
Click Resume
UART prints
message to
Termite
TM
External Use
93
2
Expand General
Registers
TM
External Use
94
Click Suspend
Changed registers
are highlighted
TM
External Use
95
TM
External Use
96
TM
External Use
97
3
Notice the program
stopped at the
Breakpoint
TM
External Use
98
Click Resume
Lab 4 Summary
TM
External Use
99
TM
www.Freescale.com
Printed SEPT2014