PAC52XX Clock Control Firmware Design



Similar documents
Hello, and welcome to this presentation of the STM32L4 reset and clock controller.

ES_LPC4357/53/37/33. Errata sheet LPC4357/53/37/33. Document information

Simplifying System Design Using the CS4350 PLL DAC

AN LPC1700 timer triggered memory to GPIO data transfer. Document information. LPC1700, GPIO, DMA, Timer0, Sleep Mode

AN4646 Application note

Software Real Time Clock Implementation on MC9S08LG32

AN111: Using 8-Bit MCUs in 5 Volt Systems

Freescale Semiconductor, Inc. Product Brief Integrated Portable System Processor DragonBall ΤΜ

AN LPC1700 RTC hardware auto calibration. Document information. RTC, Hardware Auto Calibration, LPC1700, Graphic LCD

APPLICATION. si32library. Callback CMSIS HARDWARE. Figure 1. Firmware Layer Block Diagram

STM32 F-2 series High-performance Cortex-M3 MCUs

Scanning Comparator (ScanComp) Features. General Description. Input/Output Connections. When to Use a Scanning Comparator. clock - Digital Input* 1.

AN962: Implementing Master-Slave Timing Redundancy in Wireless and Packet- Based Network Applications

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

ARM Cortex STM series

ICS514 LOCO PLL CLOCK GENERATOR. Description. Features. Block Diagram DATASHEET

Chapter 13. PIC Family Microcontroller

IRTC Compensation and 1 Hz Clock Generation

Designing an efficient Programmable Logic Controller using Programmable System On Chip

AN3332 Application note

Section 7. Oscillator

The Heartbeat behind Portable Medical Devices: Ultra-Low-Power Mixed-Signal Microcontrollers

Microtronics technologies Mobile:

Atmel Norway XMEGA Introduction

Atmel Power Line Communications. Solutions for the Smart Grid

Lab Experiment 1: The LPC 2148 Education Board

AN3998 Application note

AN2604 Application note

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

SN28838 PAL-COLOR SUBCARRIER GENERATOR

HEF4011B. 1. General description. 2. Features and benefits. 3. Ordering information. 4. Functional diagram. Quad 2-input NAND gate

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

AN AES encryption and decryption software on LPC microcontrollers. Document information

HEF4021B. 1. General description. 2. Features and benefits. 3. Ordering information. 8-bit static shift register

Serial Communications

SN54165, SN54LS165A, SN74165, SN74LS165A PARALLEL-LOAD 8-BIT SHIFT REGISTERS

UG103.8 APPLICATION DEVELOPMENT FUNDAMENTALS: TOOLS

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

AN3252 Application note

Am186ER/Am188ER AMD Continues 16-bit Innovation

Advanced Microcontrollers Grzegorz Budzyń Lecture. 3: Electrical parameters of microcontrollers 8051 family

ESP 8266: A BREAKTHROUGH IN WIRELESS SENSOR NETWORKS AND INTERNET OF THINGS

AN3265 Application note

AN974 APPLICATION NOTE

AVR1003: Using the XMEGA Clock System. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Implementing a Real-Time Clock on the MSP430

Adding WiFi to Your Embedded System. WPG Americas & Gainspan Titus Wandinger (WPG) & Su Li (Gainspan) April 23, 2013

DATA LOGGER AND REMOTE MONITORING SYSTEM FOR MULTIPLE PARAMETER MEASUREMENT APPLICATIONS. G.S. Nhivekar, R.R.Mudholker

AN2680 Application note

Using the RS232 serial evaluation boards on a USB port

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AN10866 LPC1700 secondary USB bootloader

Quad 2-input NAND Schmitt trigger

USB Audio Simplified

TRIPLE PLL FIELD PROG. SPREAD SPECTRUM CLOCK SYNTHESIZER. Features

Intel IXP42X Product Line of Network Processors and IXC1100 Control Plane Processor: Spread-Spectrum Clocking to Reduce EMI

General Porting Considerations. Memory EEPROM XRAM

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

AN486: High-Side Bootstrap Design Using ISODrivers in Power Delivery Systems

14-stage ripple-carry binary counter/divider and oscillator

Block 3 Size 0 KB 0 KB 16KB 32KB. Start Address N/A N/A F4000H F0000H. Start Address FA000H F8000H F8000H F8000H. Block 2 Size 8KB 16KB 16KB 16KB

USER GUIDE EDBG. Description

AN Boot mode jumper settings for LPC1800 and LPC4300. Document information

ZL30136 GbE and Telecom Rate Network Interface Synchronizer

HANDLING SUSPEND MODE ON A USB MOUSE

AT15007: Differences between ATmega328/P and ATmega328PB. Introduction. Features. Atmel AVR 8-bit Microcontrollers APPLICATION NOTE

1-of-4 decoder/demultiplexer

How To Use A Watt Saver On A Microcontroller (Watt Saver) On A Cell Phone Or Mp3 Player

Embedded Systems on ARM Cortex-M3 (4weeks/45hrs)

AVR1321: Using the Atmel AVR XMEGA 32-bit Real Time Counter and Battery Backup System. 8-bit Microcontrollers. Application Note.

Single Phase Two-Channel Interleaved PFC Operating in CrM

AN803. LOCK AND SETTLING TIME CONSIDERATIONS FOR Si5324/27/ 69/74 ANY-FREQUENCY JITTER ATTENUATING CLOCK ICS. 1. Introduction

APPLICATION NOTE Atmel AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

76-77 GHz RF Transmitter Front-end for W-band Radar Applications

AN11008 Flash based non-volatile storage

MPC8245/MPC8241 Memory Clock Design Guidelines: Part 1

AN LPC24XX external memory bus example. Document information

The Energy Harvesting Tipping Point for Wireless Sensor Applications

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

EEM870 Embedded System and Experiment Lecture 1: SoC Design Overview

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

Programming Audio Applications in the i.mx21 MC9328MX21

Planar PIN diode in a SOD323 very small plastic SMD package.

Current Digital to Analog Converter

STM32L. Ultra-low-power Cortex -M3 devices

3-to-8 line decoder, demultiplexer with address latches

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

Selecting the Right MCU Can Squeeze Nanoamps out of Your Next Internet of Things Application

PC Base Adapter Daughter Card UART GPIO. Figure 1. ToolStick Development Platform Block Diagram

It should be corrected as indicated by the shading below.

APPLICATION NOTE. AT07175: SAM-BA Bootloader for SAM D21. Atmel SAM D21. Introduction. Features

Freescale Semiconductor, I

RN-131-PICTAIL & RN-171-PICTAIL Evaluation Boards

The 74LVC1G11 provides a single 3-input AND gate.

AN108 IMPLEMENTING A REALTIME CLOCK. Relevant Devices. Introduction. Key Points. Overview

AN Level shifting techniques in I 2 C-bus design. Document information

ICS SYSTEM PERIPHERAL CLOCK SOURCE. Description. Features. Block Diagram DATASHEET

Application Note AN_299. FT800_FT801_Internal_Clock _Trimming

Chapter 6 PLL and Clock Generator

Transcription:

APPLICATION NOTE PAC52XX Clock Control Firmware Design TM Marc Sousa Senior Manager, Systems and Firmware www.active-semi.com Copyright 2014 Active-Semi, Inc.

TABLE OF CONTENTS APPLICATION NOTE... 1 Table of Contents... 2 Overview... 3 Clock Control System Block Diagram... 4 Clock Sources... 4 PLL... 5 Peripheral Clock Selection... 5 Using the Internal Oscillator... 6 Using the Crystal Driver... 7 Using the 4MHz Reference Clock... 8 Using the PLL... 9 Clocking in Low-Power Modes... 12 About Active-Semi... 13 2014 Copyright, Active-Semi International, Inc. - 2 - Rev 1.0 October, 2014

OVERVIEW The PAC52XX family of devices have a sophisticated clock control system that allow applications different clocking options that can allow for high-efficiency, low power and accurate time-base features. There are multiple types of system clock inputs ranging from high-accuracy RC oscillators to low-power ring oscillators, crystal drivers and external clocks. For high-frequency applications, there is a PLL that can be used to drive high-speed peripherals such as the ADC and timers, as well as flexibly configured clock dividers that allow different peripherals different clock source frequencies. For more detailed information on peripheral configuration of the clock control system, see the PAC52XX User Guide. 2014 Copyright, Active-Semi International, Inc. - 3 - Rev 1.0 October, 2014

CLOCK CONTROL SYSTEM BLOCK DIAGRAM The clock control system in the PAC52XX is shown in the diagram below. Clock Sources The clock control system has four clock input sources: CLKREF 4MHz 1% clock reference ROSC Internally generated ring-oscillator XTAL Crystal driver EXTCLK External clock input A clock source MUX is used to select the system clock source that is used from a register. The output clock from this MUX is referred to as FRCLK. CLKREF is a 1% trimmed 4MHz clock. For most applications using the PAC52XX, this clock would be the source. It is ideal for use with the on-chip PLL, because it is a highly accurate time-base. ROSC is an internally generated ring oscillator that can be configured from 8.3MHz to 28.7MHz in four steps. Because of the error in the ROSC, it is generally not recommended for applications that have highaccuracy clock needs, and not recommended for a PLL source clock. The XTAL crystal driver works with external crystal oscillators from 2MHz to 10MHz. 2014 Copyright, Active-Semi International, Inc. - 4 - Rev 1.0 October, 2014

EXTCLK allows an external clock to be supplied on PD1 as the system clock source. PLL The PAC52XX family of controllers contains a Phase Lock Loop (PLL) that can be used to multiply an accurate input clock (CLKREF) to a much higher output clock (PLLOUT). This circuit would be used for a high-frequency clock input for the Cortex-M0 core, as well as the other system peripherals such as timers, ADC, communications peripherals, etc. The PLL configuration is set via a set of registers that control the output, feedback and input divider that generate the output frequency. The clock control system allows the system clock to be selected between FRCLK and PLLCLK via another MUX. The output of this MUX is the FCLK system clock. Peripheral Clock Selection FCLK is the clock input for the two main peripheral clocks in the PAC52XX: HCLK and ACLK. All peripherals in the system are clocked from one or more of the following clock inputs: FRCLK FCLK HCLK ACLK FRCLK is the selected system clock controller clock input, and is used to clock peripherals that need to operate in the device sleep modes. The RCLK, HCLK and ACLK clocks are turned off when in some of the sleep modes of the PAC52XX. ACLK and HCLK allow dividers to divide their input clock (FCLK) to a frequency where the peripherals can efficiently operate. The table below shows all the system peripherals and which clocks are available for those peripherals during operation. Peripheral Description FRCLK FCLK HCLK ACLK RTC Real-time Clock (GP Timer) X WDT Watchdog Timer X X WIC Wakeup Interrupt Controller X ADC Analog to Digital Converter X SysTick SysTick Timer X X M0 ARM Cortex-M0 Core X SRAM SRAM X FLASH FLASH program memory X ADC EMUX Auto ADC mux selector X SOC BUS System on Chip bus X I2C I2C communications peripheral X SPI Synchronous Peripheral Interface X UART Universal Asynchronous Receive Transmit X Timers Timers A, B, C, D X X 2014 Copyright, Active-Semi International, Inc. - 5 - Rev 1.0 October, 2014

USING THE INTERNAL OSCILLATOR To use the internal oscillator (ROSC) as the system clock, the user needs to perform a few steps. The critical need is to make sure that the system clock to the ARM Cortex-M0 remains active at all times. If the MUX is switched to a clock that is not running, then the ARM Cortex-M0 will stop working and cannot be recovered until after a power cycle. To configure the internal oscillator, the user should follow these steps in this order: 1. Select the internal oscillator frequency [optional: if not planning on using the default] 2. Enable the internal oscillator 3. Switch the FCLK MUX select to FRCLK [optional: if the PLL is FRCLK] 4. Switch the FRCLK MUX select to ROSC At this point, the system will be running using the internal oscillator. At this point the user may change the HCLK and ACLK dividers, and also disable other clock sources if not needed (like the PLL). Below is the code using the PAC52XX SDK that will enable these changes. pac5xxx_sys_osc_config(oscctl_oscp_28p17mhz); // Set Frosc to desired frequency pac5xxx_sys_osc_enable(); // Enable ROSC pac5xxx_sys_ccs_config(ccsctl_clkin_intosc, // Select FRCLK = ROSC, CCSCTL_HCLKDIV_DIV1, // Set HCLK/ACLK dividers CCSCTL_ACLKDIV_DIV1); // to be /1 pac5xxx_sys_ccs_frclk_select(); // Select FCLK = FRCLK In addition, if the PLL was running and you want to save energy, you could make sure that it is disabled: pac5xxx_sys_pll_disable(); 2014 Copyright, Active-Semi International, Inc. - 6 - Rev 1.0 October, 2014

USING THE CRYSTAL DRIVER To use the crystal driver (XTAL) with an external crystal, the user needs to perform a few steps. The The critical need is to make sure that the system clock to the ARM Cortex-M0 remains active at all times. If the MUX is switched to a clock that is not running, then the ARM Cortex-M0 will stop working and cannot be recovered until after a power cycle. To configure the crystal driver, the user should follow these steps in this order: 1. Enable the crystal driver 2. Switch the FCLK MUX select to FRCLK [optional: if the PLL is FRCLK] 3. Switch the FRCLK MUX select to XTAL At this point, the system will be running using the crystal driver. The user may change the HCLK and ACLK dividers, and also disable other clock sources if not needed (like the PLL). Below is the code using the PAC52XX SDK that will enable these changes. pac5xxx_sys_xtal_enable(); // Enable XTAL pac5xxx_sys_ccs_config(ccsctl_clkin_xtal, // Select FRCLK = XTAL, CCSCTL_HCLKDIV_DIV1, // Set HCLK/ACLK dividers CCSCTL_ACLKDIV_DIV1); // to be /1 pac5xxx_sys_ccs_frclk_select(); // Select FCLK = FRCLK In addition, if the PLL was running and you want to save energy, you could make sure that it is disabled: pac5xxx_sys_pll_disable(); 2014 Copyright, Active-Semi International, Inc. - 7 - Rev 1.0 October, 2014

USING THE 4MHZ REFERENCE CLOCK The 4MHz Reference Clock (CLKREF) is a 1% trimmed oscillator that is always running, and cannot be disabled. This clock source can be used as-is, or as input to the PLL for a much higher frequency clock. This section discusses how to use the 4MHz clock as-is. If the PLL is already running, and the user wants to change to the 4MHz CLKREF, the user should follow these: Switch the FCLK MUX select to FRCLK [optional: if FRCLK = PLLCLK] At this point, the system will be running using the CLKREF. The user may change the HCLK and ACLK dividers at any time, and also disable other clock sources if not needed (like the PLL). Below is the code using the PAC52XX SDK that will enable these changes. pac5xxx_sys_ccs_config(ccsctl_clkin_clkref, // Select FRCLK = CLKREF, CCSCTL_HCLKDIV_DIV1, // Set HCLK/ACLK dividers CCSCTL_ACLKDIV_DIV1); // to be /1 pac5xxx_sys_ccs_frclk_select(); // Select FCLK = FRCLK In addition, if the PLL was running and you want to save energy, you could make sure that it is disabled: pac5xxx_sys_pll_disable(); 2014 Copyright, Active-Semi International, Inc. - 8 - Rev 1.0 October, 2014

USING THE PLL Some of the PAC52XX peripherals that require a high-frequency, accurate time-base must use the PLL. For example, the UART and Timers (A, B, C, D) and other peripherals require a high-accuracy time-base and the ARM Cortex-M0 often needs to a high-frequency clock that can only be supplied from the on-chip PLL. The PLL requires the CLKREF as its input clock. The output of the PLL (PLLCLK) is derived from the input clock and the values of the three dividers that are a part of the PLL: Feedback divider Input divider Output divider The PLLOUT frequency is calculated by the following equation: Where the following are true: PLLOUT is the PLL output frequency in MHz PLLIN is the PLL input frequency in MHz (4MHz for CLKREF) PLLINDIV is the PLL input divider (2 to 33) PLLFBDIV is the PLL feedback divider (2 to 513) PLLOUTDIV is the PLL output divider (1 to 16) In addition, the PLL configuration has constraints for the input and output divider selection, as shown below. The input clock frequency and input clock divider selection must follow the formula below: The output clock frequency and output clock divider selection must follow the formula below: The table below shows some pre-calculated PLL output frequency settings using the 4MHz CLKREF as the PLL input clock. 2014 Copyright, Active-Semi International, Inc. - 9 - Rev 1.0 October, 2014

After the PLL dividers are configured and before the PLL output can be enabled, there has to be a mandatory delay of 500us. This allows the PLL time to lock for the clock to become stabilized before the system starts using it as it s time-base. In order to simplify configuration of the PLL, the PAC52XX SDK provides some functions that allow the user to configure the PLL by calling a single function with the output frequency specified as the only argument. The function is below. pac5xxx_sys_pll_config(80); // Configure PLLOUT for 80MHz Calling this function performs the following steps: Set FRCLK to CLKREF Disable the internal oscillator (done to save energy) Configure the PLL input, feedback and output dividers Delay 500us Switch FCLK to PLLOUT It is also possible for the user to individually call each of these functions themselves by the PAC52XX SDK functions. The relevant SDK functions are shown in the table below. Function void pac5xxx_sys_ccs_pll_select(void) void pac5xxx_sys_ccs_config_dividers( uint8_t input_div, uint8_t feedback_div, uint8_t output_div); void pac5xxx_sys_ccs_pll_enable(int delay); Description Sets FCLK to be PLLOUT Configures the PLL dividers. Note that this function will not check to see if the dividers are within correct range, so the user must take care to do this according to the guidelines above. Delays for 500us. After returning from this function, the user must change the FCLK to 2014 Copyright, Active-Semi International, Inc. - 10 - Rev 1.0 October, 2014

void pac5xxx_sys_ccs_pll_disable(void) PLLOUT by calling the pac5xxx_sys_ccs_pll_select() function. Immediately disables the PLL. Before calling this, the user must make sure that the FCLK is set to FRCLK with a valid clock source, so that the system continues to have a valid clock input. 2014 Copyright, Active-Semi International, Inc. - 11 - Rev 1.0 October, 2014

CLOCKING IN LOW-POWER MODES The PAC52XX has low-power modes that allow the system to go to sleep, to consume a minimum amount of current for applications that require low quiescent current. The ARM Cortex-M0 has two low-power modes: Sleep Mode Deep Sleep Mode In Sleep Mode, the CPU is put to sleep and can be woken up by any interrupt (timers, communications, etc.). To save even more energy, deep sleep mode gates the ACLK, HCLK and some of the FCLK clocks. This effectively puts to sleep the ARM Cortex-M0 and most of the system peripherals. In this mode, only a few other peripherals are available to wake up the system: RTC (GP Timer) WDT GPIO When the system enters deep sleep mode either the RTC (GP Timer) or WDT can be configured to wake the system up by enabling the disabled clocks (ACLK, HCLK and FCLK) and interrupting the Cortex-M0. As an example, to change to deep sleep mode to save the maximum amount of energy, the firmware could implement the following: void mcu_clock_config_low_power(void) { pac5xxx_sys_ccs_config(ccsctl_clkin_clkref, CCSCTL_ACLKDIV_DIV1, CCSCTL_HCLKDIV_DIV1); pac5xxx_sys_pll_disable(); pac5xxx_arm_sleep_deep_enable(); // Configure system to use deep sleep mode pac5xxx_arm_sleep_wfi(); // Go to sleep } This function changes to the REFCLK, without the PLL, disables the PLL and then sends the system to sleep. The RTC (GP Timer) or WDT could then wake up the system via an interrupt. When this interrupt is serviced, it could then call a function like shown below that could re-configure the system for a high-speed clock: void mcu_clock_config_high_power(void) { pac5xxx_sys_ccs_config(ccsctl_clkin_clkref, CCSCTL_ACLKDIV_DIV1, CCSCTL_HCLKDIV_DIV4); pac5xxx_sys_pll_config(80); pac5xxx_sys_osc_disable(); } 2014 Copyright, Active-Semi International, Inc. - 12 - Rev 1.0 October, 2014

ABOUT ACTIVE-SEMI Active-Semi, Inc. headquartered in Dallas, TX is a leading innovative semiconductor company with proven power management, analog and mixed-signal products for end-applications that require power conversion (AC/DC, DC/DC, DC/AC, PFC, etc.), motor drivers and control and LED drivers and control along with ARM microcontroller for system development. Active-Semi s latest family of (PAC) ICs offer high-level of integration with 32-bit ARM Cortex M0, along with configurable power management peripherals, configurable analog front-end with high-precision, high-speed data converters, single-ended and differential PGAs, integrated low-voltage and high-voltage gate drives. PAC IC offers unprecedented flexibility and ease in the systems design of various end-applications such as Wireless Power Transmitters, Motor drives, UPS, Solar Inverters and LED lighting, etc. that require a microcontroller, power conversion, analog sensing, highvoltage gate drives, open-drain outputs, analog & digital general purpose IO, as well as support for wired and wireless communication. More information and samples can be obtained from http://www.activesemi.com or by emailing marketing@active-semi.com Active-Semi shipped its 1 Billionth IC in 2012, and has over 120 in patents awarded and pending approval. LEGAL INFORMATION & DISCLAIMER Copyright 2012-2013 Active-Semi, Inc. All rights reserved. All information provided in this document is subject to legal disclaimers. Active-Semi reserves the right to modify its products, circuitry or product specifications without notice. Active-Semi products are not intended, designed, warranted or authorized for use as critical components in life-support, life-critical or safety-critical devices, systems, or equipment, nor in applications where failure or malfunction of any Active-Semi product can reasonably be expected to result in personal injury, death or severe property or environmental damage. Active-Semi accepts no liability for inclusion and/or use of its products in such equipment or applications. Active-Semi does not assume any liability arising out of the use of any product, circuit, or any information described in this document. No license, express, implied or otherwise, is granted under any patents, copyrights or other intellectual property rights of Active-Semi or others. Active-Semi assumes no liability for any infringement of the intellectual property rights or other rights of third parties which would result from the use of information contained herein. Customers should evaluate each product to make sure that it is suitable for their applications. Customers are responsible for the design, testing, and operation of their applications and products using Active-Semi products. Customers should provide appropriate design and operating safeguards to minimize the risks associated with their applications and products. All products are sold subject to Active-Semi's terms and conditions of sale supplied at the time of order acknowledgment. Exportation of any Active-Semi product may be subject to export control laws. Active-Semi, Active-Semi logo, Solutions for Sustainability,, Micro Application Controller, Multi-Mode Power Manager, Configurable Analog Front End, and Application Specific Power Drivers are trademarks of Active-Semi, I. ARM is a registered trademark and Cortex is a trademark of ARM Limited. All referenced brands and trademarks are the property of their respective owners. 2014 Copyright, Active-Semi International, Inc. - 13 - Rev 1.0 October, 2014