FREESCALE - Workshop Microcontroladores
Transcripción
FREESCALE - Workshop Microcontroladores
Kinetis Microcontrollers Portfolio Presentation Gabriel Soccodato | DFAE Electrocomponentes S.A. SASE 2014 TM External Use The Kinetis Concept Kinetis is the branding for all ARM® CortexTM-M based microcontrollers Cores • Scalability Freescale uses the most advanced cores from ARMs offering: − CortexTM M4 for highest computation performance − CortexTM M0+ for lowest power and smallest packages TM External Use 2 • Depending on their capabilities they are grouped to K10/KL1, K20/KL2/KW20 etc. In a family direct scalability between these groups is given Families • Today, six Kinetis families are available. Kinetis L, K, E, M and W series are in production, first Kinetis KV01 is available and more in will be in production Q2 2014. ARMv6-M architecture ARMv7-M architecture Kinetis Series powered by ARM® Cortex™ Cortex-M4 High performance data processing & I/O control. Support hardware divide, MAC, bit field processing, DSP. Floating point unit optional (Cortex-M4F). Cortex-M3 High performance data processing & I/O control. Support hardware divide, MAC (Multiply Accumulate) , bit field processing. Cortex-M0+ General data processing, high performance I/O control, mixed signal ASICs, replacement for 8/16-bit MCUs Cortex-M0 General data processing, I/O control, mixed signal ASICs, replacement for 8/16-bit MCUs Cortex-M1 For FPGA designs only. Optimized for FPGA and can work in most FPGA devices TM External Use 3 Kinetis K Series Kinetis L Series Kinetis MCU Families more more to to come in come in Core2014 2014 K Series L Series E Series M Series W Series V Series S08P For all Series General Purpose K70 EMC/ESD Robust & 5V Supply + Graphic LCD Lowest Power/ Smallest Package Metering 24b Sigma Delta ADC & PGA Wireless Motor Sub 1-GHz Control & & Power 2.4 GHZ Conversion 8-bit Lowest Price & 5V Supply Feature Set K60 + Ethernet & Crypto K50 + Measurement K40 + USB and LCD + LCD + USB Baseline K30 K20 K10 KL3 KM3 KW2 KL2 KL1 KL0 Bridge to 8bit MCU Core: KL4 KM1 ARM® Cortex™-M0+ TM External Use KW0 KE0 ARM® Cortex™-M4 4 KV1 S08P Freescale HC9S08 Kinetis Families TM External Use 5 Kinetis K Series Design Potential. Realized with ARM® CortexTM-M4 www.freescale.com/kinetis/KSeries TM External Use 6 K Series: MCU Family Compatibility Hardware & software compatible MCU families with scalable performance, memory and feature integration IIIIIIII 72-100MHz 64-512KB 64-144pin IIIIIIII IIIIIIII TM External Use 72-100MHz 64-512KB 64-144pin IIIII IIIII I K30 I I IFamily IIII + Segment LCD 7 IIIII IIIII 50-120MHz 32KB-1MB 32-144pin I K40 I I IFamily IIII IIIII IIIII Entry Point 72-100MHz 128-512KB 64-144pin IIIIIIII IIIIIIII I K10 I I IFamily IIII I K50 I I IFamily IIII IIIII 50-120MHz 32KB-1MB 32-144pin IIIII IIIII + USB + Segment LCD + Graphics LCD IIIII 100-150MHz 256KB-1MB 100-256pin IIIII I K60 I I IFamily IIII IIIIIIII I K20 I I IFamily IIII 120-150MHz 512KB-1MB 196-256pin IIIIIIII IIIII + Ethernet, Encryption, Tamper Detect, DRAM Controller IIIII IIIII I K70 I I IFamily IIII + USB + Analog Measurement Engine, Ethernet, Encryption Kinetis K-Series: four Sub-Families available 120-150MHz, Floating Point Unit, 128KB-1MB, 64-256pin 128KB-1MB Flash, 120-150MHz, FPU 128-512KB Flash, 100MHz 100MHz 64KB-256KB Flash, 72MHz 128-512KB, 80144pin Feature Integration 32KB-512KB Flash, 50MHz 72MHz 64-256KB, 64-121pin K50 Family (Medical) Analog, USB, S. LCD, Ethernet, Encryption K60 Family Ethernet, Encryption, USB K70 Family + Graphics LCD K60 Family + USB (HS), Tamper, NAND Flash, DRAM K50 Family (Medical) Analog, USB, S. LCD, Ethernet, Encryption K40 Family USB, Segment LCD K40 Family USB, Segment LCD K30 Family Segment LCD K30 Family Segment LCD 50MHz 32-512KB, 32-121pin K20 Family USB K20 Family USB K20 Family USB K10 Family + NAND Flash K10 Family Mixed-Signal K10 Family Mixed-Signal K10 Family Mixed-Signal TM External Use 8 K20 Family + USB (HS), NAND Flash Kinetis L Series Design Made Simple with ARM® CortexTM-M0+ www.freescale.com/kinetis/LSeries TM External Use 9 Kinetis L/K Series: MCU Family Compatibility IIIII IIIII + Segment LCD 48MHz 8KB-32KB <24-48pin + Segment LCD IIIII IKL0x I I I Family IIII IIIIIIII TM External Use 10 IIIII IIIII IIIII IIIII IIIIIIII I K30 I I IFamily IIII IIIIIIII IKL3x I I72-100MHz I Family IIII IIIII IIIII I 32-80pin IIIIIII IIIIIIII 64-512KB 48MHz 64-144pin 128-256KB 64-121pin IIIII IIIII IIIII IIIII IIIII IIIII I32-121pin IIIIIII I K10 I I IFamily IIII IIIIIIII I K40 I I IFamily IIII IKL1x I I50-120MHz I Family IIII IKL4x I I72-100MHz IFamily IIII 32KB-1MB 48MHz 32-144pin 32KB-256KB IIIII IIIII IIIII 32KB-1MB 48MHz 32-144pin 32KB-256KB Entry Point 8-bit MCU Compatible I K20 I I IFamily IIII IKL2x I 50-120MHz I IFamily IIII 64-512KB 48MHz 64-144pin 64-256KB 64-121pin IIIIIIII IIIIIIII + USB I K50 I I IFamily IIII 72-100MHz 128-512KB 64-144pin IIIII IIIIIIII + Graphics LCD IIIII 100-150MHz 256KB-1MB 100-256pin IIIII IIIII I K60 I I IFamily IIII ARM Cortex-M4 ARM Cortex-M0+ 120-150MHz 512KB-1MB 196-256pin IIIIIIII + Ethernet, Encryption, Tamper Detect, DRAM Controller + USB IIIII IIIII Hardware & software compatible MCU families with scalable I K70 I I IFamily IIII performance, memory and feature integration IIIIIIII + Analog Measurement Engine, Ethernet, Encryption Kinetis L Series: Memory & Package Scalability 256KB Package Size (mm) Pitch (mm) MCU Families Samples / Qual 16QFN 3x3x1 0.5 KL02 Apr2013 / Aug2013 KL3x KL3x 4x4x1 0.5 KL05/KL04/KL02 20CSP 2 x 2 x 0.56 0.4 KL02 Q213 / Q413 25CSP 2.3 x 2.3 x 0.56 0.4 KL05 Proposed KL2x KL2x 35CSP 2.55 x 3 x 0.56 0.4 KL15/KL25 Q213 / Q313 KL1x KL1x KL4x Segment LCD Small Packages General Purpose Flash Memory Entry Level KL3x KL2x KL2x KL2x KL2x KL2x KL1x KL1x KL1x KL1x KL1x KL2x KL2x KL2x KL2x KL1x KL1x KL1x KL1x KL2x KL2x KL2x KL2x KL1x KL1x KL1x KL1x KL0x KL0x KL0x KL0x 64 LQFP 80 LQFP 32KB KL0x 16KB KL0x KL0x KL0x 8KB KL0x KL0x KL0x 24 QFN 32 LQFP / QFN 16 QFN TM 20 WLCSP External Use Small Footprint Package 11 35 WLCSP 48 LQFP /QFN Package KL2x KL3x KL3x KL0x KL2x KL4x KL3x USB 128KB Flash Memory KL4x 24QFN USB + Seg. LCD 64KB KL4x Now / Now Feb2013 / Jun2013 100 LQFP / 121 MBGA Kinetis L Series vs. Kinetis K Series Category Kinetis L Series Kinetis K Series Core, Performance ARM Cortex-M0+ (48MHz) ARM Cortex-M4 (50-150MHz) Flash 8-256KB 32KB-1MB Features Mixed-Signal, USB, Seg. LCD FlexMemory, Mixed-Signal, USB, Seg. LCD, CAN, Ethernet, Gra. LCD, DRAM, Crypto, Tamper Detect, DRAM Pin-count 16-121pin 32-256pin Low Power ~50uA/MHz (VLPR) ~200uA/MHz (VLPR) Price From $0.49 (MKL02, 8KB, 16QFN) From $0.99 (MK10, 32KB, 32QFN) Target Applications 8 &16-bit replacement Low/mid/high–end 32-bit TM External Use 12 Kinetis E Series Strong Robustness High Efficiency Low Cost with ARM® CortexTM-M0+ www.freescale.com/kinetis/ESeries TM External Use 13 Kinetis E selling points 1. Better EMC – Proven passing EFT(IEC61000-4-4) /PSED(IEC61000-4-2) tests in a Microwave single layer PCB design 2. High robustness – 5V operation provides better noise immunity 3. Reduce system cost – No additional BOM for faster response Bit-banging / SW emulation / Direct connection to LED drive circuit / Over-Current and Voltage protection / Up to 256B EEPROM to save an ext EEPROM chip 4. Easy for PCB layout – 0.8mm pin pitch for low cost PCBA assy process 5. Make platform design easier – Pin compatible with KE and S08P / Rich Eco-system / SW reusable / Save time to market TM External Use 14 Kinetis E Series: Master Block Diagram System Unique ID Cortex M0+ 48MHzM0+ Core Freq Cortex 48MHz NVICCore Freq SWD Clock Management Flash RAM 128KB RAM 16KB Flash 128KB 16KB Ext Osc (4-24M, Ext Osc 32K) (4-24M, 32K) Int LP Osc Int LP(1KHz) Osc (1KHz) CRC CRC 1-Cycle BME(1) WDT NVIC Debugger 1-CY MUL SWD GPIO 1-Cycle BME(1) WDT Debugger 1-CY MUL GPIO Int R/C OSC (~32KHz Int R/C OSC 2%) (~32KHz 2%) FLL Clock FLL Multiplier Clock Multiplier Power Management Single 2.7-5.5V Power Supply Single 2.7-5.5V Power Supply Power On PowerReset On Reset Low Voltage Detector Low Voltage Detector Peripheral Bus Peripheral Bus Analog Interfaces Timers & Triggers 16ch 12bit ADC with 8ADC FIFO 16ch 12bit with 8 FIFO 6ch + 2ch + 2ch Timer(2) 6ch16bit + 2chFlex + 2ch 16bit Flex Timer(2) 3 x SCI (LIN capable) 3 x SCI (LIN capable) 2 x ACMP 2 x ACMP 1 x PWT 1 x PWT 2 x 8bit SPI 2 x 8bit SPI 8 pins 20mA 8 pins 20mA 2 pins True Open-Drain 2 pins True Open-Drain 1 x 32bit PIT(2 ch) 1 x 32bit PIT(2 ch) 2 x IIC (1 x SMBUS) 2 x IIC (1 x SMBUS) 8 x KBI 8 x KBI Reset/Input Reset/Input 16bit Real Time Counter 16bit Real Time Counter 1 x msCAN 1 x msCAN Display 28x4/24x8 Seg LCD 28x4/24x8 Seg LCD (1) Support bit operation in RAM (2) Faster timer running 2 x core clock Pin compatible within 5V E-series on same package Temp: -40~105°C operation TM External Use 15 Serial Interfaces I/O Ports Up to 71 GPIO Up to 71 GPIO 16ch TSI 16ch TSI 80LQFP(0.65mm pitch); 64QFP (0.8mm pitch); 64LQFP(0.5mm pitch); 44LQFP (0.8mm pitch); 32LQFP (0.8mm pitch); 24QFN(0.65mm pitch); 20SOIC(1.27mm pitch); 16TSSOP(0.65mm pitch) Kinetis E Series: MCU Families Common Features Optional Features Key Features System ARM Cortex-M0+ Core, 48MHz [1] Family Speed Flash SRAM KE06Z 48MHz 64-128KB 8-16KB KE35Z 48MHz 16-32KB 2-4KB KE05Z 48MHz 16-64KB 2-8KB KE04Z 48MHz 8-128KB CAN Seg. LCD PWT Fast Timer ADC √ √ 12-bit √ √ 12-bit √ √ √ 12-bit √ √ √ 12-bit TSI Multiple power modes, Clock Gating, 2.7V – 5.5V Operating Temp: -40 to 105°C √ Clock Management External OSC, 4~20MHz, 32KHz Internal OSC, 32KHz, 1KHz Analog Peripherals √ 12-Bit ADC Analog Comparators Serial Interfaces SCI SPI, IIC Timers Real Time Clock Production KE02Z Since 2013 KE02Z-40MHz 2014 Q2 KE04Z8 2-4KB 2014 Q2 KE06Z 2014 Q2 KE04Z 2014 Q2 16bit Flex timers 32bit Periodic Interrupt Timer [1] 20MHz for KE02 KE02Z TM External Use 16 20MHz 1-16KB Family 16-64KB 12-bit Kinetis M Series Highest Precision & Security with ARM® CortexTM-M0+ www.freescale.com/kinetis/MSeries TM External Use 17 Kinetis M - Highest precision and security • • Up to 48 MHz Cortex™-M0+ with Ultra-Low-Power Analog Front End − 24-bit sigma delta ADC with 94 dB SNR − Programmable gain amplifier with gains from 1 to 32 with low temperature drift − High precision internal voltage reference with low temperature drift • Security − Tamper detection with time stamping − Random number generator, memory protection unit • Interfaces − LCD segment driver up to 288 (8x36) segments − High accuracy RTC +5 ppm over temperature range − 4x UART, 2x SPI, 2x IIC TM External Use 18 Kinetis W Series From Antenna to Bits with ARM® CortexTM-M0+ & CortexTM-M4 www.freescale.com/kinetis/WSeries TM External Use 19 Freescale Wireless Connectivity Strategy To provide all wireless solutions (from antenna to bits) required for control and monitoring applications in consumer, residential, metering, medical and industrial applications. Communications Software RF / MCU Wireless Microcontrollers • All ISM frequency bands: 315 MHz, 434 MHz, 868 MHz, 915 MHz, 2.4 GHz • Scalable wireless protocol: From simple point-to-point lightweight protocol, up to full ZigBee-compliant applications. TM External Use 20 Kinetis W – ARM® CortexTM-M & RF Transceiver • KW01 − Up to 48 MHz Cortex™-M0+ with UltraLow-Power − RF transceiver supports 290-340 MHz, 424-510 MHz, and 862-1020 MHz frequency bands • KW20 − Up to 50 MHz Cortex™-M4 with 16channel-DMA − Highly integrated 2.4 GHz RF transceiver − 802.15.4 Packet processor TM External Use 21 2.4GHz Protocol Stack Comparison Feature Typical Applications SMAC SynkroRF Cable Replacement Cable Replacement Wireless Toys and Games Wireless Control ZigBee™ RF4CE ZigBee™ 2007-PRO RF Remote Control Home Entertainment and Control Home Automation Home Automation Smart Energy 1.x Building Automation ZigBee™ IP Smart Energy 2.0 Health Care Network Stack Network Profiles Memory Requirements Network Topology Typical # of Nodes Typical IC Cost Typical Data Throughput TM No Yes Yes Yes Yes No No Yes Yes Yes 4-8K 32K <40K 80-100K 256K min Point-to-Point Co-existing Star Co-existing Star Tree Tree Star Mesh Mesh 2-100 32 per Controlled Device 32 per Target Device 2-250 ZigBee 2-1000 ZigBee Pro IP limit $1-2 $2-3 $2-3 $3-4 $4-5 70-100K 70-100K 30-70K 30-70K 50-115K External Use 22 Sub-GHz Protocol Stack Comparison Feature 23 SMAC 802.15.4g Cable Replacement Wireless Meter Reading Typical Application Building Control Medical IPv6 Wireless M-Bus Internet of Things M2M Wireless Meter Reading (Europe) Medical Standard Proprietary IEEE 802.15.4 6lowPAN EN 13757-4:2005 Network Stack No No Yes Yes Network Profiles No No No No Memory Requirements 4-8K 32K 128K 16-32K Point to Point Peer-to-Peer Network Topology Tree Star Point-to-Point IP Mesh Star Typical # of Nodes 2-100 2-100 Not limited 2-100 Data Rate 200 Kbps 50-200 Kbps 1-600Kbps 32-100 Kbps Protocol Stack Provider Freescale 3rd Party 3rd Party 3rd Party TM External Use 23 Kinetis V Series Motor & Power Control with ARM® CortexTM-M0+ & CortexTM-M4 www.freescale.com/kinetis/VSeries TM External Use 24 Kinetis V Series: Motor & Power Control • Full Kinetis portfolio compatibility targeting low cost, stand alone motor control, to high performance digital power conversion • Optimized for processing efficiency with performance ranging from 75MHz to beyond 200MHz • ARM architecture with best in class, high speed capture and control peripherals for motor control and power management applications • Enablement and tools built around reducing customer development time and cost, whilst increasing ease of use. TM External Use 25 Kinetis V-Series: 3 Phase Motor Control Entry Level FOC Motor Control Integrated Motor Control Solutions Scalable Mid Range Motor Control High Performance Motor Control Multi Ultra Domain Performance Motor Power Control w/ Control w/ Comms Comms High Performance MC & extended memory KVxx + ENET KVxx KVxx + HS ADC KVxx KVxx + Advanced Timers KVxx + Dual Motor Control KVxx + FPU KVxx KV1x KVxx KVxx KVxx KVxx KVxx KV1x Core: KVxx KVxx + USB Baseline KVxx KVxx + Management Core + Integrated Motor Control S/W KVxx ARM® Cortex™-M0+ ARM® Cortex™-M ARM® Cortex™-M Dual ARM® Cortex™-M TM External Use 26 KVxx KVxx KVxx KVxx KVxx KVxx KVxx KVxx KVxx Kinetis V Series KV1x: Overview Key Features: Core/System • 75MHz ARM CM0+ with 4ch DMA • H/W DIV & SQRT block Memory • 32KB Flash, 8KB SRAM Communications • Multiple serial ports Analog • 2 x 8ch 16-bit ADC • 835nS conversion time • 1 x12-bit DAC, • 2 x ACMP w/ 6b DAC Timers • 1x6ch FlexTimer (PWM) • 2x2ch FlexTimer (PWM/QDEC) • Programmable Delay Block Others • 32-bit CRC • Inter-module Crossbar Switch • Up to 35 I/Os • 1.71V-3.6V; -40 to 105°C Packages • 32QFN, 32LQFP, 48LQFP • Pin-to-pin compatible with K series From $1.18 to $1.37 at 10k units ARM Cortex-M0+ 75MHz Debug Interfaces HW Divide & SqrRoot Interrupt Controller Security and Integrity Cyclic Redundancy Check (CRC) Memories System Core Internal and External Watchdogs Program Flash 32KB Clocks SRAM 8KB 4ch-DMA Low/High Frequency Oscillators Inter-Module Crossbar Analog Timers 2 x16-bit ADC 6ch FlexTimer 2 x ACMP 2x2ch FlexTimer 1 x12-bit DAC Programmable Delay Block FrequencyLocked Loop Internal Reference Clocks Communication Interfaces 1xI2C HMI GPIO 2xUARTs 1xSPI Low-Power Timer A high performance, cost-optimized and best-in-class enabled 32-bit ARM Cortex-M0+ MCU for low/mid range Brushless DC and FOC PMSM Motor Control External Use 27 TM Kinetis Differentiators TM External Use 28 Kinetis Key Differentiators in Technology Security • • • Performance Hardwareaccelerated security algorithms and tamper detection Secure communication and safe operation Unique device ID for tracing and tracking • • • • Non-blocking bus-matrixswitch K Series with DSP extension in all subfamilies FLASH memory controller MPU/DMA TM External Use 29 Low Power • • • • • ~50µA/MHz for Kinetis L ~200 µA/MHz for Kinetis K Up to 11 flexible power-modes low-power wake-up logic. Supply voltage from 1.71V to 3.6V, resp. 2.7V to 5.5V Mixed Signal • • • • • 16-Bit ADCs 12-bit DACs, High Speed comparators Programmable Gain Amplifiers Precision Voltage Reference Special Features • • • • • Flex-Memory – up to 10M erase/write cycles Touch-sensing with API library EEPROM with Kinetis E Series 24b Sigma Delta ADC in M Series RF transceiver (sub-1GHz & 2.4GHz) in W Series Kinetis K/L Package Overview CSP 20 CSP 35 CSP 36 CSP 2.0x2.0mm 2.4x2.4 mm 2.5x3.0mm 0.4mm pitch 0.35mm pitch 0.4mm pitch (KL02) (KL15/25) (KL16/26) 42 CSP 2.9x2.8mm 0.4mm pitch 64 CSP 3.3x3.3mm 0.4mm pitch 100 CSP 4.6x4.8mm 0.4mm pitch 120 CSP 5.3x5.3mm 0.4mm pitch 142 CSP 4.8x5.6mm 0.4mm pitch 143 CSP 6.5x5.6mm 0.4mm pitch 169 CSP 5.6 x 5.5mm 0.4mm pitch (KL1x/2x) (K12/22) (K10/20) (K10/20/60) (K24/64) (K60/61) (K60 2M) LQFP 32LQFP 7 x 7 mm 0.8mm pitch 48LQFP 7 x 7 mm 0.55mm pitch 64LQFP 10 x 10 mm 0.5mm pitch 80LQFP 12 x 12 mm 0.5mm pitch 100LQFP 14 x 14 mm 0.5mm pitch 144LQFP 20 x 20 mm 0.5mm pitch 176LQFP 24 x 24 mm 0.5mm pitch (K10/20) (KL0x) (K10/20) (KL0x) (K10/20/30/40/50) (KL1x/2x/3x/4x) (K10/20/30/40/50) (KL1x/2x/3x/4x) (K10/20/30/40/50/60) (KL2x/3x/4x) (K10/20/30/40/50/60) (Kinetis X*) QFN 16QFN 3 x 3 mm 0.5mm pitch (KL02) BGA 24QFN 32QFN 4 x 4 mm 5 x 5 mm 0.5mm pitch 0.5mm pitch (KL0x) (K10/20) (KL0x/1x/2x) 48QFN 7 x 7 mm 0.5mm pitch (K10/20) (KL1x/2x) TM External Use 30 64 MAPBGA 5 x 5 mm 0.5mm pitch 121 MAPBGA 256 RCP 169 MAPBGA 8 x 8 mm 9 x 9 mm 9 x 9 mm 0.65mm pitch 0.5mm pitch 0.65mm pitch 144 MAPBGA 13 x 13 mm 1.0mm pitch 256 MAPBGA 17 x 17 mm 1.0mm pitch (K10/20) (KL1x*/2x*/ 3x*/4x*) (K10/20/30/ 40/50/60) (KL2x/3x/4x) (K10/20/30/ 40/50/60) (K60/70) (K61) (K60) Freescale Product Longevity Program • • • The embedded market needs long-term product support Freescale has a longstanding track record of providing long-term production support for our products Freescale is pleased to introduce a formal product longevity program for the market segments we serve − For the automotive and medical segments, Freescale will make a broad range of program devices available for a minimum of 15 years − For all other market segments in which Freescale participates, Freescale will make a broad range of devices available for a minimum of 10 years − Life cycles begin at the time of launch • For terms and conditions and to see a list of participating Freescale products available under this program: www.freescale.com/productlongevity TM External Use 31 Kinetis Enablement TM External Use 32 Kinetis Enablement Overview Kinetis MCU Enablement Freescale Bundle ARM Cortex-M0+ Core 48MHz, 1.77 CoreMark/MHz, 2-Stage Pipeline, 1-Cycle GPIO, Micro Trace Buffer Hardware Freedom board, Tower Platform ARM Cortex-M4 Core 50-150MHz, 3.40 CoreMark/MHz, HW-divide, MAC, DSPcommands, FPU option CodeWarrior, Processor Expert, Driver Suite, eGUI, PEG, FreeMASTER ARM Eco System Differentiators Low-power, Performance, FlexMemory, Mixed-Signal, Security, HMI Features Special Functions Analog Pre-Processing, 24bSigma Delta ADC, sub -1GHz & 2.4 GHz Transceiver TM External Use Software 33 RTOS MQX, MQX Lite Kinetis Development Hardware Freedom Platform Tower System • The new Freescale platform for Kinetis L and Kinetis K microcontroller • The established and proven platform with highest flexibility and re-usability • Compatible with Arduino shields • Over 50 add-on boards available. Device Specific • Reference Designs Evaluation boards addressing special functions and capabilities of Kinetis devices TM External Use 34 • Home Energy Gateway, 1ph Meter, 3ph Meter, pre-/postpaid Meter, Home Area Network, Home Display, … Kinetis Development Software IDE • • RTOS CodeWarrior – eclipse-based • Basic, Standard, Professional and Free Suite with 128k code size limit MQX - Free real-time operating system with USB & Ethernet stacks and file system • MQX Lite - Free and lightweight RTOS for small microcontrollers Processor Expert/Driver Suite – configuration and code generation tool Middleware • • Libraries & Tools eGui – Free and lightweight graphic frame-work for small microcontrollers PEG - high performance, high value tool for medium to high end MCUs with a licence fee associated TM External Use 35 • FreeMaster - Real-time monitor and control of an app • Math & Motor Control Lib Wide group of algorithms • Made For iPod - supports development and rapid prototyping of electronic accessories for iPod, iPhone and iPad devices The ARM® Eco System Use the broad support for ARM® microcontroller by many companies. • Re-use your existing… GNU Tools TM External Use 36 MCU Solution Advisor web application www.freescale.com/SolutionAdvisor The Solution Advisor helps you quickly identify best-fit processor solutions from the following portfolios: 8-bit MCU (microcontroller) Kinetis K Series MCU Kinetis L Series MCU PX Series MCU Freescale DSC (digital signal controller) Interactive MCU selector guide based on: operating characteristics packaging options memory and FlexMemory requirements a library of configurable hardware modules Dynamic, sortable, downloadable solution matrix Pin Muxing verification and suggested placement (Full functionality will be restored soon) Session and Contact Management Save, restore, invite, and share Generates session summary reports TM External Use 37 Freescale Cross Check App • Features: − − − − − Cross reference check of competitive solutions 10K budgetary resale pricing Top parametric for comparison Direct links to data sheets Additional links for package and environmental information TM External Use 38 Industrial Where you can find Kinetis designs today Medical Consumer Blood Glucose Analog & Low Power WiFi Gateway AC Motor E-Meter Wireless Power MQX & Memory Performance & IP Scalability & IP Flexibility & SW Smoke Detector Money Counter Gaming Mouse Fitness Watch Infusion Pump BOM cost & Low Power Features & BOM cost Low Power & USB Features & Timing Tools & Support Coffee Maker Scalability & Features Air Bed Pump Performance & Peripherals Card Reader HVAC Control Guitar Effect Security & IP ADC & Analog NAND & Audio TM External Use 39 • Energy Efficiency KINETIS SERIES DESIGN POTENTIAL. REALIZED • Ultra-Scalable • Market’s most scalable portfolio of low-power ARM Cortex-M0+ and ARM Cortex-M4 MCUs with over 700 hardware and software compatible devices Mixed Signal Exceptional integration with fast 16-bit ADCs, DACs, PGAs and more. Powerful, cost-effective signal conversion, conditioning and control The world’s most energyefficient and scalable MCU Series with power optimized peripherals and flexible power modes Comprehensive Enablement Freescale MQX RTOS, Tower System and Eclipse-based CodeWarrior IDE, as well as Kinetis support from most ARM ecosystem providers TM External Use 40 Herraminetas SW CW10.x (Hoy CW 10.6) KDS+SDK (Hoy Beta 1.0.1) PE Eclipse+GCC TM External Use 41 SW asociado MQX/MQX Lite FreeRTOS USB stack KxxxxSC TM External Use 42 Concepto Freedom OpenSDA: Open-Standard Serial And Debug Adapter El circuito de debugging integrado, OpenSDA, brinda además de debugger puerto serie virtual. El OpenSDA tiene un bootloader “mass storage device”, que proporciona un mecanismo fácil y rápido para cargar diferentes aplicaciones a la interfaz OpenSDA como; programadores de flash, debuggers, conersores serial-to-USB y otros: • La interfaz de programación de Freescale que usa “mass storage device” elimina la necesidad de instalar herramientas para evaluar aplicaciones en forma rápida • P&E Multilink: provee un debugger compatible con los diferentes IDEs • SEGGER™ OpenSDA: provee un debugger compatible con los diferentes IDEs (JLINK Lite) • Interfaz mbed: provee debugger para las herramientas online con soporte de virtual serial port, CMSIS-DAP, y mass-storage programming interface • CMSIS-DAP(stand alone): Nuevo estándar ARM para debugging TM External Use 43 FRDM-KL46Z MKL46Z256VLLZ4 MCU (48 MHz, 256KB Flash, 32 KB RAM, Low power, 100LQFP) Dual role USB interface with mini-B USB connector Open SDA 4 digit segment LCD module Capacitive touch slider Ambient light sensor MMA8451Q accelerometer MAG3110 Magnetometer 2 user LEDs 2 user push buttons Flexible power supply options – USB, coin cell battery, external source Battery-ready, power-measurement access points Easy access to MCU I/O via Arduino ™ R3 compatible I/O connectors Programmable OpenSDA debug interface with multiple applications available including: o Mass storage device flash programming interface o P&E Debug interface provides run-control debugging and compatibility with IDE tools o CMSIS-DAP interface: new ARM standard for embedded debug interface o Data logging application Arduino R3 compatibility TM External Use 44 Kinetis L Series: KL46 Family Block Diagram System ARM Cortex-M0+ Core Ultra-low power 48MHz bus freq. Flash RAM 128-256K 16-32K Clock Management Unique ID COP Debug (SWD) Crystal Oscillator LPO (1KHz ) RST DMA 4-ch LS Osc (32KHz) (low & high range) Voltage Regulator Power On Reset ULP Osc (4MHz) PLL FLL Energy Management Low Voltage Detector Peripheral Bus Analog Interfaces ADC (SAR w/ DMA) 12/16-bit, up to 16ch 12-bit DAC Operation in: HSCMP Run Connectivity Timers SRTC LPTMR Temp. Compensated Stop/ VLPS Wait Packages: 64LQFP, 100LQFP, 121MBGA TM External Use UART x2 16b LPTPM 6ch x1, 2ch x 2 PIT 2ch, 32bit 45 VLLS 3 LPUA RTx1 Connectivity IIS x1 Up to 80 GPIO (4 High Dive) w/ 25 interrupt USB FS/LS Transceiver SPI x 2 USB Controller I2C x 2 V Regulator VLLS 1 I/O Ports VLLS 0 TSI x 16ch HMI Segment LCD 51x8/55x4 RST/ Input Volvemos a FRDM-KL46Z TM External Use 46 OpenSDA TM External Use 47 Ejemplo 1 “Demo de KL-46Z” TM External Use 48 Ejemplo 1 - “Demo de KL-46Z” 1-Saque la placa FRDM de su caja 2-Conecte el cable USB mini a su PC 3-Probablemente sea necesario instalar el driver del adaptador serie. En tal caso; siga los pasos para instalar driver de dispositivo USB en Windows, elija la opción “Instalar automáticamente” TM External Use 49 Ejemplo 1 - “Demo de KL-46Z” 4-Verificar en el panel de control el puerto COM en el que se ha instalado el puerto serie virtual CDC del OpenSDA. 5-Abrir la terminal una terminal de puerto serie. En nuestro caso contamos con “putty” que está en la ruta siguiente: Escritorio\Workshop Aplicaciones con Cortex M de Freescale\Terminal\hercules.exe 6-Seleccione la configuración para el puerto serie para que trabaje a 115200,8,N,1 y abra el puerto indicado para este driver TM External Use 50 Ejemplo 1 - “Demo de KL-46Z” 7-Probar las prestaciones de la placa de acuerdo con la siguiente descripción comenzando por presionar el botón de reset TM External Use 51 Ejemplo 1 - “Demo de KL-46Z” 8-Verifique la información que se muestra en el puerto serie. 9-¿Que significan los datos? TM External Use 52 Ejemplo 2 – OpenSDA como bootloader MSD TM External Use 53 Ejemplo 2 – OpenSDA como bootloader MSD 1-Busque en un administrador de archivos el disco extraíble FRDM-KL46Z. 2-Busque la carpeta con las aplicaciones pre-compiladas Escritorio\FRDM_KL46Z_QSP\FRDM-KL46Z_QSP\Precompiled Examples\ 5-Copie de esta carpeta y pegue en el disco extraíble, las aplicaciones de la carpeta de arriba: freedom_red_led_freedom.srec, freedom_green_led_freedom.srec y sLCD_freedom_freedom.srec 6-Vea feedback por la terminal de puerto serie TM External Use 54 Ejemplo 3 – Bootloader del Bootloader “Cambiando la funcionalidad de la interfaz OpenSDA” TM External Use 55 Ejemplo 3 – Bootloader del Bootloader 1-Desconecte la placa del USB 2-Presione botón de reset 3-Conecte USB con botón de reset presionado 4-Suelte botón de reset 5-Aparecerá un nuevo disco extraíble (BOOTLOADER) 6-Ir a la carpeta: Escritorio\FRDM_KL46Z_QSP\FRDM-KL46Z_QSP\OpenSDA Applications\ 7-Programar copiando y pegando en el disco extraíble la aplicación DEBUG-APP_Pemicro_v108.SDA TM External Use 56 Ejemplo 3 – Bootloader del Bootloader 8-Desconectar USB y volver a conectarlo 9-Instalar los drivers (Pide dos drivers, CDC y Debugger) 10-Debe quedar instalado el debugger y el CDC como se ve debajo 11-Tomar nota del número de puerto serie virtual 12-Modificar en la terminal para conectarse al puerto serie virtual nuevo, si este ha cambiado TM External Use 57 Ejemplo 4 – Mi Primer Proyecto con CodeWarrior TM External Use 58 Ejemplo 4 - Creación del Proyecto 1-Abrir CodeWarrior: Inicio->Programas->Freescale->Freescale CodeWarrior->CW for MCU v10.6->CodeWarrior 2-Especificar Workspace. El workspace es una carpeta que contenerá los proyectos. Se puede especificar cualquier nombre para esta carpeta y se puede tener muchas distintas. Presionar ok. TM External Use 59 Ejemplo 4 - Creación del Proyecto 3-Se debe abrir el Workbench del CW que nos permitirá trabajar con nuestros proyectos. 4-En CodeWarrior workbench, ir a [File -> New -> Bareboard Project] 5-Ingrese el nombre del proyecto, por ejemplo “primerEj4KL46” y haga click en [Next]. TM External Use 60 Ejemplo 4 - Creación del Proyecto 6-Con la ventana de selección del MCU, en la línea [Device or board to be used], ingrese el MCU KL46 y elija el target final MKL46Z256 de la lista, luego haga click en [Next] 7-En la ventana Connections elegimos [OpenSDA]y [Segger JLink/J-Trace/SWO(SWD)based] y hacemor click en [Next] TM External Use 61 Ejemplo 4 - Creación del Proyecto 8-En la ventana Language and Build Tools Options deje todo en estado default. Revice que el lenguaje is [C] y que se halla esté tildada la opción [Software] en Floating Point, no hay hardware floating point unit (FPU) en los Kinetis L. Nota: A partir de CodeWarrior 10.3 el soporte para Kinetis L lo da el compilador GCC, el que está seleccionado como se ve como [GCC]. Continua haciendo click en [Next]. TM External Use 62 Ejemplo 4 - Creación del Proyecto 9-Deje las opciones por default y haga click en [Finish]. El CodeWarrior creará el proyecto y hará todos los seteos necesarios agregando la estructura de directorios y los archivos requeridos. TM External Use 63 Ejemplo 4 – Compilando 10-Hacemos doble click sobre main.c para ver el código en el editor, main.c está dentro de la carpeta source del proyecto que podemos ver en la venta CodeWarrior Projects. 11-Compilamos el proyecto haciendo click sobre el martillo Nota 1: si hay errores en la compilación los podemos ver en la ventana Problems Nota 2: los resultados y la realimentación del proceso de compilación lo podemos ver en la ventana Console TM External Use 64 Ejemplo 4 – Descargando 12-Descargamos el proyecto al MCU haciendo click sobre el escarabajo Nota: la primera vez que se intenta descargar un proyecto, es necesario decirle al IDE que target descargar. Si la acción provoca el siguiente mensaje: 12.1-Hay que configurar el target para hacer la descarga. Lo podemos hacer desplegando el nemú asociado al escarabajo. 12.2-Hacemos click en [Debug Configurations...] TM External Use 65 Ejemplo 4 – Descargando 12.3-Desplegamos las opciones debajo de CodeWarrior y hacemos click en primerEjKL46_FLASH_OpenSDA. Presionamos [Debug] Nota: este procedimiento no será necesario en cuando volvamos a descargar el proyecto. TM External Use 66 Ejemplo 4 –Debuggeando 13-La perspectiva de debugging se abrirá automáticamente. Probamos los diferentes controles de debugging para familiarizarnos 14-Cerramos la sesión al terminar presionando el botón de stop y volvemos al editor TM External Use 67 Ejemplo 4 – Usando CW con KL46_SC 15-Volvemos a la perspectiva de edición 16-Repetimos los pasos los pasos del ejemplo 3 para cambiar la funcionalidad de la interfaz OpenSDA. Desconectamos el Freedom de USB y lo volvemos a conectar con el reset presionado. Luego soltamos el reset. 17-Copiar y pegar en el disco BOOTLOADER la aplicación siguiente: c:\Documents and Settings\Administrador\Escritorio\Workshop Aplicaciones con Cortex M de Freescale\FRDM-KL46Z_QSP\OpenSDA Applications\JLink_OpenSDA.sda TM External Use 68 Ejemplo 4 – Usando CW con KL46_SC 18-Desconectar la Freedom del USB y volver a conectarlo. Si nos pide instalar drivers, procedemos como lo hacemos habitualmente en Windows. 19-Verificar que la herramienta está oinstalada correctamente en el Administrador de dispositivos de Windows http://www.segger.com/opensda.html Licensing SEGGER created a firmware which runs on the Freescale OpenSDA platform, making it JLink compatible. In order to make use of this firmware, the following Terms Of Use must be accepted:The firmware is only to be used with Freescale target devices. Using it with other devices is prohibited and illegal. The firmware is for use with evaluation boards only. It is not for use with custom hardware. The firmware may only be used for development and/or evaluation purposes. It may not be used for production purposes. The firmware is made available without any warranty and without support. TM External Use 69 Ejemplo 4 – Usando CW con KL46_SC 20-Compilamos y descargamos la aplicación nuevamente, repitiendo los pasos 11 y 12, pero ahora ante el cuadro de dialogo que nos pide elegir la herramienta seleccionamos platinum_FLASH_Segger J-Link_Trace. Aceptar las condiciones de licencia de Segger. 21-Debuggear la aplicación. 22-Finalizar la sesión de debugging y volver a la perspectiva de edición. 23-Reestablecer el debugger de P&E siguiendo los pasos 1 a 8 del Ejemplo 3 TM External Use 70 Ejemplo 5 – Agregamos control de GPIO a mamo TM External Use 71 Ejemplo 5 – Configuración de puertos Cada pin tiene un registro PCR (32-bit) dedicado. • Ejemplo.: En nuestro MKL46 de 100 pines, “Pin 26” corresponde con PORTE bit 29 tiene el registro asociado PORTE_PCR29, en el que puedo configurar solo para este pin : • − − − − − − − − Interrupt flag (w1c ) Interrupt configuration : int/dma, edge/level, low/high, rising/falling/both Mux control : can select Disabled (analog) or Alternate function Alt1 -> Alt7 Drive Strenght low/high Open drain yes/no Slew Rate : fast/slow Pull Resistor Enable : yes/no, pull-up or pull-down Passive filter enable : optional passive lowpass filter (10-30MHz BW ) Los seteos configurados en PCR siempre tienen afecto, sin importar que módulo se conectó al pin a travéz del MUX TM External Use 72 Configuración de puertos – Clock Gating TM External Use 73 Configuración de puertos – PIN MUX – PORTx_PCRxx TM External Use 74 Configuración de puertos - Control del puerto TM External Use 75 Configuración de puertos - Ejemplo Habilito el clock // Habilitación de clock para GPIO SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK ); Habilito pin como GPIO PORTE_PCR29 = (PORT_PCR_MUX(1) | PORT_PCR_DSE_MASK); Seteo valor inicial GPIOE_PSOR = (1<<29); Lo configuro como salida GPIOE_PDDR = (1<<29); TM External Use 76 Ejemplo 5 – Manejo de GPIO 1-Importamos las fuentes que nos permiten manejar las GPIO al proyecto anterior. 2-Parados sobre la carpeta Sources del proyecto, hacemos click con el botón derecho y elegimos Import… 3-Desplegamos [General] y elegimos [File System], luego presionamos [Next]. TM External Use 77 Ejemplo 5 – Manejo de GPIO 4-Elegimos [Browse]. 5-Navegamos hasta Escritorio\Workshop Aplicaciones con Cortex M de Freescale\Fuentes de Ejemplo\Ej5\ y presionamos [Aceptar]. 6-Desplegamos [General] y elegimos [File System], luego presionamos [Next]. 7-Tildamos gpio.c y gpio.h y presionamos [Finish]. 8-Editamos la función main para hacer parpadear los leds que están el PTD5 y PTE29. 9-Compilamos y descargamos el programa al MCU. TM External Use 78 Ejemplo 5 – Manejo de GPIO 10-¿Se ven los leds parpadear? 11-¿Qué debemos hacer para que se vean parpadear? 12-¿Cómo lo haríamos de manera más elegante? 13-¿Cómo puedo hacer para controlar la frecuencia de parpadeo? TM External Use 79 Ejemplo 6 – GPIO+Systick TM External Use 80 Systick Timer de 24-bits que está en el core, cuente en forma descendente desde el valor de recarag a cero. Cuando llega a cero, se recarga con el valor almacenado en el registro SYST_RVR y sigue contando. Permanece detenido cuando el debugger encuentra un breakpoint. • Este timer lo comparten todos los Cortex M de ARM independientemente del fabricante porque forma parte del core como el NVIC. Sus registros se encuentran en las mismas posociones en todos los MCUs • TM External Use 81 Systick TM External Use 82 Ejemplo 6 – GPIO+Systick 1-Importamos las fuentes que nos permiten manejar el Systick 2-Navegamos hasta Escritorio\Workshop Aplicaciones con Cortex M de Freescale\Fuentes de Ejemplo\Ej6\ y presionamos [Aceptar]. 3-Desplegamos [General] y elegimos [File System], luego presionamos [Next]. 4-Tildamos SysTick.c y SysTick.h y presionamos [Finish]. La carpeta Sources del proyecto debe quedar como indica la figura TM External Use 83 Ejemplo 6 – GPIO+Systick 6-Agregamos acceso a las funciones de Systick en main.c 7-Inicializamos Systick para interrumpir cada 1ms 8-Compilamos y descargamos el programa. 9-Colocamos un breakpoint en la línea indicada dentro de la rutina de interrupción del Systick y corremos el programa para ver si el Sistick está operativo 10-¿Cómo hacemos para que el Systick controle la conmutación del led en el loop principal de programa y que esta sea cada 1s? De este modo podemos prescindir de la demora por software que usamos. 11-¿El parpadeo es cada 1s?¿Porqué? TM External Use 84 Ejemplo 6 – GPIO+Systick 12-Repita los pasos 1 a 4 para importar oscilador.c y oscilador.h 13-Agregamos acceso a las funciones de oscilador en main.c 14-Inicializamos el oscilador 15-Compilamos y descargamos el programa. 16-¿Cuál es la frecuencia parpadeo? TM External Use 85 Ejemplo 7 – Usamos los ejemplos de Freescale TM External Use 86 Ejemplo 7 – Usando CW con KL46_SC 1-Cerramos el proyecto anterior. 2-Importamos un proyecto de ejemplo del paquete KL46_SC, para esto vamos a File->Import… 3-Seleccionar General>Existing Projects into Workspace y presionamos Next TM External Use 87 Ejemplo 4 – Usando CW con KL46_SC 4-Presionar [Browse…] para buscar el proyecto según indica la figura 5-Presionar [Aceptar] 6-Asegurarse que el tilde Copy Projects into Workspace no esté seleccionado. Presionar [Finish] TM External Use 88 Ejemplo 4 – Usando CW con KL46_SC 7-Hacemos doble click sobre paltinum.c TM External Use 89 Ejemplo 4 – Usando CW con KL46_SC 7-Compilamos la aplicación haciendo click sobre el martillo 8-Si no hubo errores, descargar la aplicación presionando el escarabajo 9-Elegir platinum_FLASH_OpenSDA, que es nuestra herramienta TM External Use 90 Ejemplo 4 – Usando CW con KL46_SC 10-Probar controles de debugging 11-Verificar mensaje en la terminal serie 12-Volvemos al editor y cerramos el proyecto TM External Use 91 Ejemplo 8 –Proyecto nuevo y manejo de GPIO con KL46_SC TM External Use 92 Clonando proyecto platinum 1-Ejecutar Escritorio\Workshop Aplicaciones con Cortex M de Freescale\kinetis_kl46_sc_rev2\klxx-sc-baremetal\build\cw\ make_new_cw_project.exe 2-Ingresar nombre del proyecto y presionar Enter. EL nombre del proyecto puede ser Ej8KL46 3-Presionar Enter para cerrar el script. TM External Use 93 Estructura Necesaria del Proyecto Clonado El proyecto nuevo se ha creado de forma compatible con la estructura de proyectos del paquete KL46_SC que tiene soporte para gran cantidad de periféricos del MCU y para las plataformas de desarrollo como la FRDM que estamos usando. Vemos el proyecto creado. Ahora necesitamos copiar algunas fuentes porque el proyecto quedó configurado para buscarlas en la ruta indicada en la figura de la izquierda. Todas las fuentes están en la carpeta src; las comunes, los drivers y las aplicaciones y fuentes propias de cada proyecto. TM External Use 94 Importando el nuevo proyecto 1-Importamos el nuevo proyecto repitiendo los pasos 2 a 6 del proyecto anterior 2-Intentamos abrir las fuentes creadas por default en el proyecto, obtendremos el mensaje de error que se muestra en la pantalla. Esto sucede porque el proyecto es un clon del proyecto base platinum, que probamos en el ejemplo anterior, y no sus fuentes. TM External Use 95 Importando las fuentes necesarias 3-Borramos las fuentes de la carpeta project 4-Creamos una carpeta con el nombre del proyecto dentro de la ruta siguiente Escritorio\Workshop Aplicaciones con Cortex M de Freescale\kinetis_kl46_sc_rev2\klxx-scbaremetal\src\projects\ 5-Copiamos allí las fuentes de la carpeta Escritorio\Workshop Aplicaciones con Cortex M de Freescale\Fuentes de Ejemplo\Ej8\ 6-Importamos a project las fuentes de la carpeta anterior La carpeta project debe quedar como indica la figura de la derecha Nota: No debe tener el tilde en Overwrite existing… TM External Use 96 Compilando el proyecto 7-Si hacemos click sobre el nombre del proyecto para resaltarlo y luego presionamos el botón derecho, al abrirse el menú elegimos Clean Project para eliminar archivos generados que pueden hacer fallar la compilación 8-Compile el proyecto seleccionando Project Build Project o click en el ícono del martillo 9-Debuggeamos el proyecto presionando el ícono del escarabajo 10-Probamos la funcionalidad del proyecto anterior TM External Use 97 Agregando código 8-Cerramos la sesión de debugging. 9-Editamos platinum.c: Agregamos #include “GPIO.h” Agregamos gpio_init(); Modificamos el lazo principal para que quede: LED1_OFF; LED2_OFF; ch =in_char(); LED1_ON; LED2_OFF; out_char(ch);LED1_OFF; LED2_ON; 10-Compilamos y debuggeamos paso a paso la aplicación TM External Use 98 Problema 11-Nos encontramos con un problema; si no debuggeamos por pasos no vemos los leds. ¿Cómo lo resolvemos? Modificamos agregando demoras y volvemos a compilar y debuggear pero ahora haciendo correr el programa 12-Probamos los cambios y cerramos la sesión de debugging y el proyecto 13-Cerramos la sesion de debugging, volvemos al editor y cerramos el proyecto. TM External Use 99 Ejemplo 9 - PE • Programaremos un LED con una frecuencia fija de blinking LEDs Rojo y Verde KL46Z 256VLL4 TM External Use 10 0 PTD5(ROJO) PTE29/TPM0_CH2(VERDE) Concepto Hay muchas formas de hacer parpadear un LED. • Usaremos un PWM lento para cambiar el estado del pin de I/O. • Usaremos CW10.6 y Processor. • Necesitamos los componentes siguentes de PE: • − CPU (Cpu:MKL46Z256VLL4), setear oscilador externo y habilitar el PLL. − Timer Unit (TimerUnit_LDD), en modo PWM para generar una señal de blinking lenta. TM External Use 10 1 Componentes Cpu:MKL46Z256VLL4 • • Es el componente básico del proyecto, es agregado en forma automática. La CPU, el PLL, etc. son motorizados por el Multipurpose Clock Generator (MCG), y este asu vez por el oscilador externo (OSC). TM External Use 10 2 Clock del Sistema CPU 48 MHz 96 MHz Bus 24 MHz TPM 48 MHz 8.0 MHz TM External Use 10 3 Configuración de Componente Cpu:… • Propiedades − System oscillator 0: enabled - switch osc on − Clock source: External crystal - use crystal − Clock frequency: 8.0 - crystal frequency − MCG mode: PEE - enable PLL mode − PLL output: 96.0 - set PLL frequency − Core clock: 48.0 - set CPU frequency − Bus clock: 24.0 - set bus frequency • Methods − none • Events − none TM External Use 10 4 Componente: TimerUnit_LDD (TPM-Mode) • Basado en Timer/PWM Module (TPM) El TPM està hecho en base al timer simple de los MCU de o bits de Freescale (HCS08 Timer PWM Module – TPM). El TPM funciona en los modos de bajo consumo TM External Use 10 5 Funcionalidad del Timer Counter value El contador del TPM0 cuenta con un período de 175ms configurado como “Period value”. Cuando el contador alcanza el valor “Compare” del canal 0 configurado en 80ms setea la salida. Cuando el contador se reinicia, la salida se resetea. Counter period Channel 0 offset value Time TMP0_CH1 output pin state (LED) TM External Use 10 6 Configuración de Componente TimerUnit_LDD blinking LED demo • Propiedades − Counter: TPM0_CNT- Timer/PWM Mode − Counter frequency: 375 kHz - set input frequency − Overrun period: 174.763 ms- set PWM frequency − Channel list: 1 - use one channel − Mode: Compare - channel is compare − Compare: TPM0_C1V - compare register − Offset: 80 ms - ~50% duty cycle − Output on compare:Set - behavior on compare − Output on overrun: Clear - behavior on overrun − Output pin: ADC0_SE5b/PTD1/… − Auto initialization: yes - called from the CPU • Methods − none • Events − none TM External Use 10 7 Creación del Proyecto 1-En CodeWarrior workbench, ir a [File | New | Bareboard Project]. 2-Ingrese el nombre del proyecto, por ejemplo “KL46Z-PE_Lab1” y haga click en [Next]. 3-Con la ventana de selección del MCU, en la línea [Device or board to be used], ingrese el MCU KL46 y elija el target final MKL46Z256 de la lista, luego haga click en [Next] TM External Use 10 8 Creación del Proyecto 4-En la ventana Connections elegimos [OpenSDA]y [Segger JLink/J-Trace/SWO(SWD)based] y hacemor click en [Next] 5-En la ventana Language and Build Tools Options deje todo en estado default. Revice que el lenguaje is [C] y que se halla esté tildada la opción [Software] en Floating Point, no hay hardware floating point unit (FPU) en los Kinetis L. 6-A partir de CodeWarrior 10.3 el soporte para Kinetis L lo da el compilador GCC, el que está seleccionado como se ve como [GCC]. Continua haciendo click en [Next]. TM External Use 10 9 Creación del Proyecto 7-En la ventana Rapid Application Development eleja [Processor Expert] y deje [Use current perspective]. Elija [Standalone]en Project Mode y go haga click en [Finish]. El Processor Expert creará el proyecto y hará todos los seteos necesarios agregando la estructura de directorios y los archivos requeridos, esta estructura se puede ver en ProcessorExpert.pe en la carpeta de proyecto. TM External Use 11 0 Configuración de los Componentes 8-Abra la vista de Processor Expert seleccionando Processor Expert Show view: 9-Seleccione la CPU en la ventana Components, como se muestra debajo 10-Elegir vista avanzada 11-Configuramos el oscilador como se muestra en la imágen siguiente del Component Inspector TM External Use 11 1 Configuración de los Componentes Las líneas en rojo indican errores producidos por seteos que no pueden lograrse. Los cambios que debemos hacer respecto del default son los siguientes: • System Oscillator 0: Enabled • Clock Frequency: 8MHz • MCG Mode: PEE • PLL module: Enabled • PLL output: 96MHz • Core Clock: 48MHz • BUS Clock: 24MHz Al terminar los seteos, todos los errores deben desaparcer quedando todo el texot en negro. TM External Use 11 2 Configuración de los Componentes 12-Abrir Component Library y seleccione y arrastre TimerUnit_LDD de Components Library a Components view del proyecto: 13-Renombre el componente ”TimerUnit_LDD” de TU1 a PWMTimer usando el botón derecho para abrir el menú de contextocomo se muestra debajo: TM External Use 11 3 Configuración de los Componentes 14-En el Component Inspector de [PWMTimerB/ Properties] setee los siguientes valores (Cambie a la vista a Advanced o Expert ): 15-Se debe elegir el pin de salida, en nuestro caso PTE29 y cambiará la selección de compare a TMP0_C2V. Cambios: 1. Counter: TMP0_CNT 2. Counter Frequency: 375kHz 3. Overrun Period: 174,762667ms 4. Channel List: 1 5. Mode: Compare 6. Compare: TPM0_C2V 7. Offset: 80ms 8. Output on compare: Set 9. Output on overrun: Clear 10. Initial State: Low 11. Output pin Signal: PTE29 12. Autoinitialization: yes TM External Use 11 4 Configuración de los Componentes 16-Ahora hay que ejecutar el generador de código de Processor Expert (PEx) presionando generate button en Components view: 17-Para simplificar la vista, reseteamos la vista de la perspectiva actual usando el menu [Window Reset Perspective] TM External Use 11 5 Código Fuente 18-Luego de la generación de código, el proyecto tiene nuevos archivos que pueden verse en CodeWarrior Projects. Abrir el archivo Source\main.c con dobleclick en él. Se abrirá en el editor. 19-En el editor de main.c exploremos la función main(void). La función PE_low_level_init() inicializa todos los drivers de bajo nivel generados por Procesor expert y también el componente PWMTimer. TM External Use 11 6 Compilar y correr el proyecto 20-Compile el proyecto seleccionando Project Build Project o click en el ícono del martillo 21-Conecte el cable USB a la placa 22-Comience la sesión de debugging haciendo click en el botón de debug, compilará y linkeará todo el proyecto. Dependiendo de la configuración del debugger, elija el que correspondapara FRDM-KL46Z board. Puede ser OpenSDA o Segger J-Link. El debugger de CodeWarrior’s comenzará la descarga del binario ejecutable a la Flash del MCU target. TM External Use 11 7 Compilar y correr el proyecto 23-Luego de que finalice la descarga, la vista de la pantalla cambiará a la perspectiva de Debug. Si no cambia, cambiela usted haciendo click en el botón Debug como se muestra en la figura 24-Comience la ejecución de la aplicación presionando [F8] o el ícono Resume El LED rojo de la FRDM-KL46Z comenzará a parpadear. Estamos generando una señal PWM de 5.7 Hz con un duty cycle de aprox. 50%. Nota: El duty cicle de la señal podrá cambiarse con el offset en PWMTimer. 25-Probar que pasa cambiandolo TM External Use 11 8 Variante • Los LEDs de la placa están conectados del modo siguiente: − LED ROJO a PTE29/TMP0_CH2 − LED VERDE a PTD5/TPM0_CH5 25-Agregue al componente PWMTimer el canal del LED VERDE para hacer lo mismo que hicimos pero con ambos LEDs. 26-Modifique el ejercicio anterior para que el comportamiento de los LEDs sea inverso. TM External Use 11 9 Muchas gracias TM www.Freescale.com © 2014 Freescale Semiconductor, Inc. | External Use