Está en la página 1de 108

Hands-On Workshop: Getting

Started with Kinetis Design


Studio IDE - Basic
AMF-DES-T1678
Gordy Carlson | Field Application Engineer
O C T. 2 0 1 5

TM

External Use

Agenda

Kinetis Design Studio IDE


Features,

Roadmap/Release Dates, Support model, IDE


Partners/Ecosystem

Lab 1: Preparing the FRDM-64F Board


Installing

mBed and P&E OpenSDA drivers, drag and drop


demos to mBed, resetting board to default.

Lab 2: Project Design with Processor Expert


Blink

an LED using a periodic timer interrupt: Create project,


configure the clock, configure pin settings and GPIO,
Create a periodic timer interrupt, Generate Processor Expert
software, Modify the timer ISR routine, Build the project.

Lab 3: (Optional) Adding a Simple UART Interface


Configure

UART, generating Processer Expert software,


integrate PE drivers into main, build +debug.
Additional KDS debug feature discussion.
TM

External Use

Kinetis Design Studio

TM

External Use

Learn more at: www.freescale.com/KDS

Kinetis Design Studio


No-cost integrated
development environment
(IDE) for Kinetis MCUs

Eclipse and GCC-based IDE


for C/C++ editing, compiling
and debugging

Libraries
(DSP, Math,
Encryption)

Application
Specific

Middleware

Stacks

(TCP/IP, USB)

Software and Hardware


Evaluation & Dev Tools

Customer Application

Operating
System

BSP, Drivers &


HAL

Bootloader

MCU Hardware

TM

External Use

Product Features
A free of charge and unlimited IDE
for Kinetis MCUs
A basic IDE that offers robust editing,
compiling and debugging
Based on Eclipse, GCC, GDB and
other open-source technologies
Includes Processor Expert with
Kinetis SDK integration
Host operating systems:

Windows 7/8
Linux (Ubuntu, Redhat, Centos)
Mac OS X

Support for SEGGER, P&E and Open


SDA/CMSIS-DAP debugger targets
Support for Eclipse plug-ins including
RTOS-awareness (i.e. MQX,
FreeRTOS)
CodeWarrior project importer

Learn more at: www.freescale.com/ProcessorExpert

Freescale Processor Expert Software


Create, configure, generate
software and drivers for
Freescale microcontrollers.

Product Features
Standalone or Integrated for

Master complex peripherals with a


few mouse clicks, without the
need to read thousands of data
sheet pages.

Libraries
(DSP, Math,
Encryption)

Application
Specific

Middleware

Stacks

(TCP/IP, USB)

Software and Hardware


Evaluation & Dev Tools

Customer Application

Operating
System

BSP, Drivers &


HAL

Bootloader

MCU Hardware

TM

External Use

Eclipse based IDE's


Freescale Kinetis Design Studio IDE
Freescale CodeWarrior
IAR Embedded Workbench
Keil MDK

Supports Kinetis, S08, S12, S12Z,


ColdFire, DSC and Power Architecture
with reusable software components
Knowledge base of pins, registers,
muxing, clocks and dependencies
Initialization and driver code generation
with design time consistency checking
Bare Metal and RTOS drivers
On-chip and Off-chip Device Drivers
Middleware and Stacks: RTOS, TSS
libraries and communication stacks
Component Development Environment
(CDE) to create and distribute own
components

Learn more at: www.freescale.com/KSDK

Kinetis Software Development Kit (SDK)


SDK

A complete software framework for Product Features


developing applications across all Open source Hardware Abstraction Layer
(HAL) provides APIs for all Kinetis
Kinetis MCUs
HAL, peripheral drivers, libraries,
middleware, utilities, and usage
examples.

Libraries
(DSP, Math,
Encryption)

Application
Specific

Middleware

Stacks

(TCP/IP, USB)

Software and Hardware


Evaluation & Dev Tools

Customer Application

Operating
System

BSP, Drivers &


HAL

Bootloader

MCU Hardware

hardware
resources
BSD-licensed set of peripheral drivers
with easy-to-use
C-language APIs
Comprehensive HAL and driver usage
examples and sample applications for
RTOS and bare-metal.
CMSIS-CORE compatible startup and
drivers plus CMSIS-DSP library and
examples
RTOS Abstraction Layer (OSA) with
support for Freescale MQX, FreeRTOS,
Micrium uC/OS, bare-metal and more
Integrates USB and TCP/IP stacks, touch
sensing software, encryption and
math/DSP libraries, and more
Support for multiple toolchains including
GNU GCC, IAR, Keil, and Kinetis Design
Studio

TM

External Use

The OSI logo trademark is the trademark of Open Source Initiative.

Freescale IDEs Supporting Kinetis MCUs

KDS 1.0-Beta
Kinetis K Series:

KDS 1.0 GA

K24F, K63F, K64F

Kinetis K Series:

K22FN256, 512

K65F, K66F
K22FN128

K11D, K12D, K21D, K22D


K21F, K22F

Kinetis V Series:

Kinetis L Series:

All

KL03Z
KL14Z, KL15Z,

Kinetis W Series:

KL24Z, KL25Z
KL16Z, KL26Z

Kinetis E, L & K

KL34Z, KL36Z, KL46Z

KDS 2.0 GA
KDS 3.0 GA

Eclipse, GCC, and


plug-in updates

All
TBD

CW MCU 10.6.x

CW MCU 10.6

CW MCU 10.5
Kinetis E Series:

Kinetis E Series:

KE02Z

Kinetis K Series:

KE02Z, KE04Z, KE06Z


KEAZN8/64/128

K21F, K22F

Kinetis V Series:

Kinetis M Series:

KV10Z

KM13Z, KM14Z,
KM32Z, KM33Z,

Kinetis K Series:

Yearly Maintenance Release

10.6 Update 1
Kinetis K Series:
K6xF new product support
K20 updates

K24F, K63F, K64F

KM34Z, KM38Z

3Q

4Q

2013

1Q

2014

2Q

3Q

1Q

4Q

2Q

2015

CodeWarrior for Microcontrollers


Kinetis Design Studio
Product Public Release (right edge)

TM

External Use

Kinetis IDE Options (www.freescale.com/kide)


Featured IDEs:
Atollic TrueSTUDIO

Keil Microcontroller Development Kit

Professional ECLIPSE/GNU based IDE with a MISRA-C


checker, code complexity analysis and source code
review features.

Specifically designed for microcontroller applications,


easy to learn and use, yet powerful enough for the most
demanding embedded applications

Advanced RTOS-aware debugger with


ETM/ETB/SWV/ITM tracing, live variable watch view and
fault analyzer. Dual-core and multi-processor debugging.

ARM C/C++ build toolchain and Execution Profiler and


Performance Analyzer enable highly optimized programs

Strong support for software engineering, workflow


management, team collaboration and improved software
quality.

Complete Code Coverage information about your


program's execution

Green Hills MULTI

Complete & integrated software and hardware


environment with advanced multicore debugger

Industry first TimeMachine trace debugging & profiler

EEMBC certified top performing C/C++ compilers

IAR Embedded Workbench

A powerful and reliable IDE designed for ease of use with


outstanding compiler optimizations for size and speed

The broadest Freescale ARM/Cortex MCU offering with


dedicated versions available with functional safety
certification

Support for multi-core, low power debugging, trace, ...

Complimentary Solutions:
Kinetis Design Studio

mbed Development Platforms

Complimentary basic capability integrated development


environment (IDE) for Kinetis MCUs

The fastest way to get started with Kinetis MCUs

Eclipse and GCC-based IDE for C/C++ editing, compiling


and debugging

Online project management and build tools no


installation required; option to export to traditional IDEs

Includes comprehensive set of drivers, stacks and


middleware with a large community of developers.

Additional Ecosystem Partners:

TM

External Use

Kinetis IDE Comparison


Atollic TrueStudio Pro

Free version / Limitations


Processor Expert support
IDE Framework
Debugger
Compiler
Standard Libraries

Run Control Interfaces

Trace/Profiling Support
Kinetis SDK Support
Freescale MQX Kernel /
Task Awareness
Other RTOS Support
Includes

Green Hills MULTI

TrueSTUDIO Lite: 32KB


8KB for Cortex-M0(+)
Yes
Improved/simplified
Eclipse
GDB + proprietary
extensions
Atollic GNU gcc v4.7.3
newlib v1.19
newlib-nano v1.0
libstdc++ v6.0.17

IAR Embedded
Workbench for ARM
(EWARM)

Keil PRO Edition


Microcontroller Development Kinetis Design Studio
Kit (MDK)

Yes

Evaluation: 30-days
KickStart Edition: 32KB
Yes

Proprietary

Proprietary/Eclipse

Proprietary

Eclipse

Multi

IAR C-SPY

uVison

GDB

Multi

IAR icc/c++

armcc

GNU gcc 4.8

Multi

IAR DLIB/CMSIS

ARM MicroLib
ARM Standard

newlib 1.19
newlib-nano 1.0

Evaluation: 30 days

MDK Lite: 32KB

Unlimited

Yes

Yes

GHS Probe, GHS


P&E, SEGGER, CMSIS-DAP
SuperTrace Probe,
I-jet, P&E, SEGGER,
ULINK, ULINKpro, CMSIS-DAP,
P&E, SEGGER,
(coming soon), gdbserver
OpenOCD, CMSIS-DAP OpenOCD, CMSIS-DAP
P&E, SEGGER
OpenOCD/CMSIS-DAP
compatible probes
(coming soon)
Yes
Yes
Yes
Yes
No
1.0 GA
1.0 GA
1.0 GA
1.0 GA
Yes

Yes

Yes

Coming Soon

FreeRTOS, uC/OS

uvelOSity

FreeRTOS, uCos

FreeRTOS, uCOS, Keil RTX

FreeRTOS, uCos

TM

External Use

Additional Resources
Community
www.freescale.com/community
KDS Community + Online Experts
https://community.freescale.com/community/kinetis/kinetis-design-studio
Web
www.freescale.com/kds
Outstanding resource
Level 2 Support
www.freescale.com/kds/support
Other:
ARM mBed
ARM mBed CMSIS DAP
ARM CMSIS
Segger OpenSDA support
P&E OpenSDA support

KDS Online Training Videos


KDS Online Training by Eric Styger
Freescale Online Training All Topics
Processor Expert
MCUon Eclipse Blog + Tips

Freescale FRDM-K64F Development Board + Downloads


FRDM-K64F OpenSDA Summary+ Drivers
TM

External Use

Lab 1: OpenSDA and Preparing


the FRDM-K64F Board

TM

External Use

10

The FRDM-K64F Board and Debug Interface

TM

External Use

11

FRDM-K64F is an ultra-low-cost
development platform for
Kinetis K64, K63, and K24
MCUs. this board is already
widely used among Freescale
customers.

The FRDM-K64F platform


features OpenSDAv2, the
Freescale open source
hardware embedded serial and
debug adapter running an open
source bootloader. This circuit
offers several options for serial
communication, flash
programming, and run-control
debugging. Users can choose JLink interface, P&E OpenSDA
interface, or Mbed interface. For
each of the option, users need
update debugger firmware on
the FRDM-K64F board first.

OpenSDA on the FRDM-K64F Board

K20 with OpenSDA


USB Debug
Connector

K64 Target

TM

External Use

12

Preparing the FRDM-K64F Board

Green LED Blinking

Unplug the USB cable


Reset Button
USB Connection

Press and hold the Reset button


Plug in the USB Cable
Release the Reset button
Green LED Blinking
A removable drive should now be visible in the Windows Explorer
with a volume label of BOOTLOADER

TM

External Use

13

Preparing the FRDM-K64F Board

Drag & Drop the DEBUG_K64F_MBED_PEMICRO_v108.BIN to


the BOOTLOADER

TM

External Use

14

Preparing the FRDM-K64F Board

Before

After
Green LED ON

TM

External Use

15

Unplug the USB


Re-Plug the USB
BOOTLOADER
Disappears
Check for solid Green
LED
You are ready to go!

Preparing the FRDM-K64F Board


Check for solid Green LED
You are ready to go!

Green LED ON

Note: After programming board


via KDS or other IDE, you can
return to default OOB program
by installing mbed OpenSDA
and then dragging/dropping
OutOfBox_demo.bin onto it.

TM

External Use

16

Lab 2: Project Design with


Processor Expert

TM

External Use

17

Project Definition
Hardware: FRDM-K64F
Clock Configuration
Internal PLL; set to 120MHz
Bus Clock; 60MHz
Flash Clock: 24MHz

Pin Muxing
GPIO; UART

Blink the Blue LED


Interrupt timer; set at 500ms

Demonstrate UART (Optional)


Switch 2; Press to send a message

TM

External Use

18

Lab2: Project Design with Processor Expert

Create the Project

Configure the Clock

Configure the Pin Settings

Configure GPIO Control for the LEDs

Configure a Periodic Timer Interrupt

Generate Processor Expert Software

Modify the Periodic Timer Interrupt Service Routine

Build and Debug

TM

External Use

19

Launch Kinetis Design Studio (KDS)

Select your Workspace C:\DwF\workspace

TM

External Use

20

Welcome Screen
Starts
IDE

Live Links

TM

External Use

21

File New Kinetis Design Studio Project


3

TM

External Use

22

Name the Project

TM

External Use

23

Select the Target Platform

Boards Kinetis FRDM-K64F


6

TM

External Use

24

Select Processor Expert Software


If Demo laptops have
SDK installed, select
None

Enable Processor Expert


8

Select Standalone Project Mode


9

then Finish

10

TM

External Use

25

Default KDS C/C++ Perspective Layout

11

Double-Left-Mouse-Click on
Project Explorer tab

TM

External Use

26

Examine the Project Files

Generated_Code
Files

in this folder are automatically generated and


maintained
Do Not Modify these files

Project_Settings
Linker

Command File
Basic ARM start up code

Sources
User

application code
Standard main.c
Interrupt service routines are places in Events.c by
default
Double-Left-Mouse-Click on
Project Explorer tab again
TM

External Use

27

Lab2: Project Design with Processor Expert


Create the Project

Configure the Clock

Configure the Pin Settings

Configure GPIO Control for the LEDs

Configure a Periodic Timer Interrupt

Generate Processor Expert Software

Modify the Periodic Timer Interrupt Service Routine

Build and Debug

TM

External Use

28

Multipurpose Clock Generator (MCG)

TM

External Use

29

Investigate MCU Clock Settings

13
Double-Left-Mouse-Click on
Component Inspector - Cpu tab

12

TM

External Use

30

Change the MCU Clock Settings

Default Kinetis MCU Clock Settings are:


32.768

kHz Internal Reference Clock (IRC) is the Clock Source


FLL Enabled Internal (FEI) mode with Multiplication Factor of 640:
Core

Clock = 20.97152 MHz


Bus Clock = 20.97152 MHz
Flash Clock = 10.48576 MHz

FRDM-K64F
Ethernet

Transceiver provides a 50 MHz external clock reference


Reconfigure clocks for maximum speeds:
Core

Clock = 120 MHz


Bus Clock = 60 MHz
Flash Clock = 24 MHz

TM

External Use

31

Change the MCU Clock Settings

14
15

16
Select the System oscillator 0 tab
Make sure that System oscillator 0 is selected

17

Select the External reference clock


Change the Clock Frequency to 50 MHz

TM

External Use

32

Change the MCU Clock Settings

19

18

20

21

Select Advanced
Select the Clock source settings tab
Select the MCG settings tab
Scroll down

TM

External Use

33

Change the MCU Clock Settings

22
Change the MCG mode to PEE
for PLL Engaged External
Change the PLL output to 120 MHz
Scroll up

23

24

TM

External Use

34

Change the MCU Clock Settings

25

26

Select the Clock configurations tab


Scroll down

TM

External Use

35

Change the MCU Clock Settings

Change the Core clock to 120 MHz


Change the Bus clock to 60 MHz
Change the External bus clock to 60 MHz
Change the Flash Clock to 24 MHz

27

28

29
30
TM

External Use

36

Disable the NMI pin functionality

34

32

33
Scroll up
Select the Common settings tab
Unselect the NMI pin
Double-Left-Mouse-Click on
Component Inspector - Cpu tab

TM

External Use

37

31

Lab2: Project Design with Processor Expert


Create the Project

Configure the Clock

Configure the Pin Settings

Configure GPIO Control for the LEDs

Configure a Periodic Timer Interrupt

Generate Processor Expert Software

Modify the Periodic Timer Interrupt Service Routine

Build and Debug

TM

External Use

38

Configure Pin Settings as per the FRDM-K64F Schematic

GPIO LEDs
UART

GPIO Switches

TM

External Use

39

Configure Pin Settings as per the FRDM-K64F Schematic

Port Number

Function Name

Direction

PTA4

SW3

Input

PTB21

LED_BLUE

Output

PTB22

LED_RED

Output

PTC6

SW2

Input

PTE26

LED_GREEN

Output

TM

External Use

40

Configure the Pin Settings

36
Double-Left-Mouse-Click on
Component Inspector pin_mux tab

35

TM

External Use

41

Configure the Pin Settings PTA4 : SW3

37

38
Select the GPIO tab
Find PTA : General purpose IO pin 4

Select PTA4/LLWU_P3/FTM0_CH1.NMI_b/EZP_CS_b

TM

External Use

42

Configure the Pin Settings PTA4 : SW3

Change the Signal Name to SW3

39

40
Right-Mouse-Click and Select Pin Functional Properties

TM

External Use

43

Configure the Pin Settings PTA4 : SW3

41
Make sure that the Pullup is Enabled

TM

External Use

44

Configure the Pin Settings PTB21 : LED_BLUE

42

43

44

Scroll down
Find PTB : General purpose IO pin 21
Change the Signal Name to LED_BLUE
Change the Direction to Output

TM

External Use

45

Configure the Pin Settings PTB22 : LED_RED

Find PTB : General purpose IO pin 22


Select PTB22/SPI2_SOUT/FB_AD29/CMP2_OUT
Change the Signal Name to LED_RED
Change the Direction to Output

46

45
47

TM

External Use

46

Configure the Pin Settings PTC6 : SW2

Scroll down
Find PTC : General purpose IO pin 6
Change the Signal Name to SW2

48

50
Right-Mouse-Click and Select Pin Functional Properties

TM

External Use

47

49

Configure the Pin Settings PTC6 : SW2

51
Make sure that the Pullup is Enabled

TM

External Use

48

Configure the Pin Settings PTE26 : LED_GREEN

52

54

In Case of Pin Conflict:


Select Pins View Mode

53

Select the Selected Function for Pin 33


Make sure that only PTE/port/26 is enabled

Then select Done


and return to Collapsed View Mode
TM

External Use

49

Configure the Pin Settings PTE26 : LED_GREEN

57
Double-Left-Mouse-Click on
Component Inspector pin_mux tab

Scroll down

Find PTE : General purpose IO pin 26


Change the Signal Name to LED_GREEN
Change the Direction to Output

55

56
TM

External Use

50

Lab2: Project Design with Processor Expert


Create the Project

Configure the Clock

Configure the Pin Settings

Configure GPIO Control for the LEDs

Configure a Periodic Timer Interrupt

Generate Processor Expert Software

Modify the Periodic Timer Interrupt Service Routine

Build and Debug

TM

External Use

51

Configure GPIO Control for the LEDs

58
Double-Left-Mouse-Click on
Components Library tab

TM

External Use

52

Configure GPIO Control for LED_BLUE

62

59

Open CPU Internal Peripherals folder

Open Port I/O folder

60

61

Double-Left-Mouse-Click on BitIO
Select the Component Inspector Bit1 tab

TM

External Use

53

Configure GPIO Control for LED_BLUE


63

Change the Component name to LED_BLUE


Change the Pin for I/O to LED_BLUE
Change the Direction to Output
Change the Init. value to 1
Select the Methods tab

TM

External Use

54

Configure GPIO Control for LED_BLUE


65

66
Enable code generation for NegVal

64

Select the Properties tab


Select the Components Library tab

TM

External Use

55

Configure GPIO Control for LED_RED

68
Double-Left-Mouse-Click on BitIO

Select the Component Inspector Bit1 tab

67

TM

External Use

56

Configure GPIO Control for LED_RED


69

Change the Component name to LED_RED


Change the Pin for I/O to LED_RED
Change the Direction to Output
Change the Init. value to 1
Select the Methods tab

TM

External Use

57

Configure GPIO Control for LED_RED


71

72
Enable code generation for NegVal

70

Select the Properties tab


Select the Components Library tab

TM

External Use

58

Configure GPIO Control for LED_GREEN

74
Double-Left-Mouse-Click on BitIO

Select the Component Inspector Bit1 tab

73

TM

External Use

59

Configure GPIO Control for LED_GREEN


75

Change the Component name to LED_GREEN


Change the Pin for I/O to LED_GREEN
Change the Direction to Output
Change the Init. value to 1
Select the Methods tab

TM

External Use

60

Configure GPIO Control for LED_GREEN


77

78
Enable code generation for NegVal

76

Select the Properties tab


Select the Components Library tab

TM

External Use

61

Lab2: Project Design with Processor Expert


Create the Project

Configure the Clock

Configure the Pin Settings

Configure GPIO Control for the LEDs

Configure a Periodic Timer Interrupt

Generate Processor Expert Software

Modify the Periodic Timer Interrupt Service Routine

Build and Debug

TM

External Use

62

Configure a Periodic Timer Interrupt

81
Open Timer folder

Double-Left-Mouse-Click on TimerInt
Select the Component Inspector TI1 tab

79

80

TM

External Use

63

Configure a Periodic Timer Interrupt

82

Change the Component name to Periodic


Change the Periodic interrupt source to FTM0_C0V
Change the Interrupt period to 500 ms
Double-Left-Mouse-Click on Components Inspector Periodic tab

TM

External Use

64

Lab2: Project Design with Processor Expert


Create the Project

Configure the Clock

Configure the Pin Settings

Configure GPIO Control for the LEDs

Configure a Periodic Timer Interrupt

Generate Processor Expert Software

Modify the Periodic Timer Interrupt Service Routine

Build and Debug

TM

External Use

65

Generate Processor Expert Software

83
Select the Generate Processor Expert Code icon

TM

External Use

66

Lab2: Project Design with Processor Expert


Create the Project

Configure the Clock

Configure the Pin Settings

Configure GPIO Control for the LEDs

Configure a Periodic Timer Interrupt

Generate Processor Expert Software

Modify the Periodic Timer Interrupt Service Routine

Build and Debug

TM

External Use

67

Find the Periodic Timer Interrupt Service Routine


Open Periodic TimerInt
Double-Left-Mouse-Click on Periodic_OnInterrupt
The Editor will open the corresponding file Events.c
where the Interrupt Service Routine is located

84

85

TM

External Use

68

Modify the Periodic Timer Interrupt Service Routine

Create a space under the comment:


/* Write your code here */

Close Periodic TimerInt


Open LED_BLUE:BitIO

86

Select and Drag NegVal into the


Interrupt Service Routine

87

TM

External Use

69

Lab2: Project Design with Processor Expert


Create the Project

Configure the Clock

Configure the Pin Settings

Configure GPIO Control for the LEDs

Configure a Periodic Timer Interrupt

Generate Processor Expert Software

Modify the Periodic Timer Interrupt Service Routine

Build and Debug

TM

External Use

70

Build the Project

89

88

90

Select the Lab project


Then Build
Select the Console tab
to see the time for the Build

TM

External Use

71

Configure the Debugger

91

92

Select Debug pull-down menu


Select Debug Configurations

TM

External Use

72

Configure the Debugger

93

To create a New PEMicro Debug Interface,


Double-Left-Mouse-Click on GDB PEMicro Interface Debugging tab
Be sure that the FRDM-K64F board is connected via USB

TM

External Use

73

Configure the Debugger and Launch


94

95

96
Select the Debugger tab
Change the Interface to OpenSDA Embedded Debug - USB Port

The Port should change to USB1 - OpenSDA


if not, then select Refresh
remember, the FRDM-K64F must be connected

97

Change the Device Name to K64FN1M0M12


Select Apply then Debug to Launch the Debugger

98
TM

External Use

74

Switch to the Debug Perspective

99

TM

External Use

75

100

Run the Program

101

Select the Resume (F8) icon

TM

External Use

76

Halt the Program

102

103

104

Select the Suspend icon


Select the Terminate (Ctrl+F2) icon
(you may need to do this twice)
Return to the C/C++ Perspective

TM

External Use

77

Lab2: Project Design with Processor Expert

Create the Project


Configure the Clock
Configure the Pin Settings

Configure GPIO Control for the LEDs

Configure a Periodic Timer Interrupt


Generate Processor Expert Software
Modify the Periodic Timer Interrupt Service Routine
Build and Debug (Optional Add Red and Green LED NegVal PE code,

build, and debug..to get additional colors)

TM

External Use

78

Lab 3: (Optional) Adding a


Simple UART Interface

TM

External Use

79

Lab3: Adding a Simple UART Interface

Configure a Terminal Emulator

Configure a UART

Create a Switch Input

Generate Processor Expert Software

Create Software to Use the UART

Build and Debug

Test the Switch and UART

Setting Breakpoints

TM

External Use

80

Launch Termite

Find and use the OpenSDA CDC Serial Port


Select Settings

TM

External Use

81

Configure Termite

TM

External Use

82

Lab3: Adding a Simple UART Interface


Configure a Terminal Emulator

Configure a UART

Create a Switch Input

Generate Processor Expert Software

Create Software to Use the UART

Build and Debug

Test the Switch and UART

Setting Breakpoints

TM

External Use

83

Configure Pin Settings as per the FRDM-K64F Schematic

GPIO LEDs
UART

GPIO Switches

TM

External Use

84

Configure Pin Settings as per the FRDM-K64F Schematic

Function

Port Number

Pin Number

Uart0 TX

PTB17

62

Uart0 RX

PTB16

63

TM

External Use

85

Configure the UART Interface

Double-Left-Mouse-Click on the Components Library tab

TM

External Use

86

Configure the UART Interface

Open Communication folder

Double-Left-Mouse-Click on AsynchroSerial
Select the Component Inspector AS1 tab

TM

External Use

87

Configure the UART Interface

8
Change the Component name to Debug

Select Settings tab

TM

External Use

88

Configure the UART Interface

10

Verify:
the Receiver pin is PTB16/SPI1_SOUT/UART0_RX/FTM_CLKIN0/FB_AD17/EWM_IN
the Transmitter pin is PTB17/SPI1_SIN/UART0_TX/FTM_CLKIN1/FB_AD16/EWM_OUT_b
Set the Baud rate to 115200
Double-Left-Mouse-Click on Components Library tab
TM

External Use

89

Lab3: Adding a Simple UART Interface


Configure a Terminal Emulator

Configure a UART

Create a Switch Input

Generate Processor Expert Software

Create Software to Use the UART

Build and Debug

Test the Switch and UART

Setting Breakpoints

TM

External Use

90

Create a Switch Input : SW2

12
Double-Left-Mouse-Click on BitIO

Select the Component Inspector Bit1 tab

11

TM

External Use

91

Create a Switch Input : SW2

13

Change the Component name to SW2


Change the Pin for I/O to SW2
Change the Direction to Input
Double-Left-Mouse-Click on Component Inspector - SW2 tab

TM

External Use

92

Lab3: Adding a Simple UART Interface


Configure a Terminal Emulator

Configure a UART

Create a Switch Input

Generate Processor Expert Software

Create Software to Use the UART

Build and Debug

Test the Switch and UART

Setting Breakpoints

TM

External Use

93

Generate Processor Expert Software

Select the Generate Processor Expert Code icon

14

When done
Double-Left-Mouse-Click on main.c tab

15

TM

External Use

94

Lab3: Adding a Simple UART Interface


Configure a Terminal Emulator

Configure a UART

Create a Switch Input

Generate Processor Expert Software

Create Software to Use the UART

Build and Debug

Test the Switch and UART

Setting Breakpoints

TM

External Use

95

Create a Simple printstring() Routine

#include "Init_Config.h"
/* User includes (#include below this line is not maintained by Processor Expert) */

16

void printstring (char* ptr)


{
while (*ptr != 0)
{
while (Debug_SendChar(*ptr) == ERR_TXFULL) {}
ptr++;
}
}

/*lint -save -e970 Disable MISRA rule (6.3) checking. */


int main(void)

TM

External Use

96

Create a Simple Loop in main()


/*lint -save -e970 Disable MISRA rule (6.3) checking. */
int main(void)
/*lint -restore Enable MISRA rule (6.3) checking. */
{
/* Write your local variable definition here */

17

uint32_t delay_count;
/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization.
***/

/* Write your code here */


/* For example: for(;;) { } */

18

for (;;)
{
if (SW2_GetVal() == 0)
{
for (delay_count = 500000; delay_count != 0; delay_count--) {}
if (SW2_GetVal() == 0)
{
printstring ("Hello World\r\n");
}
while (SW2_GetVal() == 0) {}
}
}
/*** Don't write any code pass this line, or it will be deleted during code generation. ***/

TM

External Use

97

Lab3: Adding a Simple UART Interface


Configure a Terminal Emulator

Configure a UART

Create a Switch Input

Generate Processor Expert Software

Create Software to Use the UART

Build and Debug

Test the Switch and UART

Setting Breakpoints

TM

External Use

98

Build the Project

20

19
Build
When done
Double-Left-Mouse-Click on main.c tab

TM

External Use

99

Launch the Debugger

21
Directly Select the Debug icon
This will automatically select
the previous Debug Configuration

TM

External Use

100

Run the Program

22

Select the Resume (F8) icon

TM

External Use

101

Lab3: Adding a Simple UART Interface


Configure a Terminal Emulator

Configure a UART

Create a Switch Input

Generate Processor Expert Software

Create Software to Use the UART

Build and Debug

Test the Switch and UART

Setting Breakpoints

TM

External Use

102

Press SW2

TM

External Use

103

Lab3: Adding a Simple UART Interface


Configure a Terminal Emulator

Configure a UART

Create a Switch Input

Generate Processor Expert Software

Create Software to Use the UART

Build and Debug

Test the Switch and UART

Setting Breakpoints

TM

External Use

104

Setting Breakpoints

24

23

Select the Suspend icon


Select the Reset icon
Double-Left-Mouse-Click on the side bar
to set a breakpoint

25

TM

External Use

105

Lab3: Adding a Simple UART Interface


Configure a Terminal Emulator

Configure a UART

Create a Switch Input

Generate Processor Expert Software

Create Software to Use the UART

Build and Debug

Test the Switch and UART

Setting Breakpoints

TM

External Use

106

TM

www.Freescale.com

2015 Freescale Semiconductor, Inc. | External Use

También podría gustarte