17.01.2015 Views

Microcontroller Solutions TechZone Magazine, April 2011 - Digikey

Microcontroller Solutions TechZone Magazine, April 2011 - Digikey

Microcontroller Solutions TechZone Magazine, April 2011 - Digikey

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

MICROCONTROLLER LIGHTING SOLUTIONS SOLUTIONS<br />

TZ TL101.US M 112.CA<br />

Look Inside Today’s<br />

Connectivity Protocols!<br />

uIP TCP/IP<br />

Protocol Stack<br />

Demonstration<br />

Page 22


Leading-Edge<br />

Suppliers<br />

for Your<br />

Leading-Edge<br />

Designs


MICROCONTROLLER SOLUTIONS<br />

TZ M 112.CA<br />

Digi-Key Corporation brings you <strong>TechZone</strong>s SM featuring suppliers,<br />

products and resources for Lighting, <strong>Microcontroller</strong>, Power, Sensor,<br />

and Wireless technologies, with more sites to come. Resources<br />

include application notes, reference designs, white papers, links to<br />

product training modules, and more!<br />

Quick Way to Find Digi-Key’s <strong>TechZone</strong>s SM :<br />

• Links located on our homepage<br />

• Links located in our header under Resources<br />

• Links located in our toolbar<br />

• www.digikey.ca/techzones<br />

uIP TCP/IP Protocol<br />

Stack Demonstration<br />

contributed by Renesas Corporation<br />

The popular open source uIP TCP/IP stack is widely used in embedded<br />

designs. This demo provides both hands on experience and<br />

insights into its use.<br />

22<br />

<strong>2011</strong> DIGI-KEY CATALOGUE<br />

AVAILABLE NOW!<br />

View our environmentally-friendly interactive<br />

and PDF catalogues online or request your<br />

annual Digi-Key print catalogue today!<br />

www.digikey.ca/catalogue<br />

www.digikey.ca/microcontroller<br />

3


Table of Contents<br />

Digi-Key Features<br />

Editorial Comment ................................................... 5<br />

<strong>Microcontroller</strong> <strong>TechZone</strong> SM Q & A ............................<br />

6<br />

Trivia Contest ......................................................... 39<br />

Innovations in Connectivity:<br />

a look inside Digi-Key’s<br />

state-of-the-art Weather Center ............................. 47<br />

The Ultra-Low-Power USB Revolution ......................... 7<br />

by Bhargavi Nisarga, Keith Quiring, and Les Taylor, Texas Instruments<br />

USB is a fast, convenient connectivity interface, but until recently it<br />

hasn’t been associated with low-power. New MCUs have made it an<br />

attractive choice for ultra-low-power embedded applications.<br />

USB-Based Temperature Monitor .............................. 12<br />

contributed by Analog Devices<br />

If you need to be able to detect small variations in temperature, an<br />

RTD or thermocouple won’t do it. Using a thermocouple, an analog<br />

MCU, an LDO and a few discretes, you can construct a highly accurate<br />

temperature sensing application.<br />

Introducing a Second MCU<br />

to Embedded Designs ................................................. 15<br />

by Nicholas Cravotta<br />

Adding a second MCU to your embedded design addresses a number<br />

of design issues, but not without adding some complex new ones.<br />

This article focuses on inter-processor communications and how to<br />

both avoid and/or solve the issues that arise.<br />

Eliminating the Parallel/Serial Tradeoff<br />

in Embedded Systems with<br />

SPIFI-Equipped Cortex-M3 ......................................... 19<br />

by Rob Cosaro and Gene Carter, NXP Semiconductors<br />

The SPIFI peripheral creates a way for designers to use a small,<br />

inexpensive serial fl ash where they might previously have needed<br />

to use a larger, more expensive parallel fl ash to meet the system’s<br />

performance requirements.<br />

ColdFire Ethernet for Diverse Applications ................ 26<br />

by Eric Gregori, Freescale Semiconductor<br />

Adding Ethernet to embedded products provides a level of<br />

connectivity never before available in the embedded space. This<br />

article provides a detailed tutorial, an example application and XML<br />

code to quickly get you comfortable with embedded Ethernet.<br />

Your MCU is Just Starting to be Connected ............... 36<br />

by Tom Starnes, Industry Analyst, Objective Analysis<br />

Embedded applications, like individual PCs, become more useful<br />

when they can communicate with other devices. A wide range of<br />

protocols has been developed to enable such communication, but that<br />

work is far from over.<br />

Deeply Embedded Devices:<br />

The “Internet of Things” ............................................. 40<br />

by Mark Wright and Rodger Richey, Microchip Technology Inc.<br />

Wi-Fi has long worked well to connect PCs and embedded devices.<br />

However, it’s not known for being low-power and is hardly an obvious<br />

choice for deeply embedded devices. That’s about to change.<br />

Peripheral Reflex System<br />

Avoids MCU Overload ................................................. 44<br />

contributed by Energy Micro<br />

Energy Micro’s Peripheral Refl ex System minimizes MCU loading by<br />

enabling peripheral modules to communicate with each other without<br />

processor intervention. This article details how it works and why.<br />

CAN Primer: Creating Your Own Network .................. 48<br />

by Bob Boys, ARM<br />

CAN is a sophisticated network well suited to any number of<br />

automotive, industrial and consumer applications. This article takes<br />

an in-depth look at the protocol, its implementations and implications<br />

for embedded designs.<br />

Power Debugging ARM Cortex-M3<br />

and Cortex-M4 Applications ...................................... 58<br />

by Lotta Frimanson and Anders Lundgren, IAR Systems<br />

Power debugging is based on the ability to sample the power<br />

consumption of a system and correlate each sample with the source<br />

code. ARM Cortex-M3 and –M4 cores provide the architectural hooks<br />

and IAR provides the software to make this possible.<br />

The Heartbeat Behind<br />

Portable Medical Devices: Ultra-Low-Power<br />

Mixed-Signal <strong>Microcontroller</strong>s .................................. 61<br />

by Shahram Tadayon, Silicon Laboratories<br />

In the medical device market, products must combine accurate<br />

analog measurements with high reliability and ultra-low-power<br />

consumption. Fortunately, there are some integrated mixed-signal<br />

MCUs that can deliver on all three requirements.<br />

USB 3.0—Are We There Yet ...................................... 64<br />

by John Donovan, Low-Power Design<br />

SuperSpeed USB promises a 10x speed improvement over USB 2.0<br />

while maintaining compatibility with legacy devices. If your next<br />

application involves streaming video, take a look at what it has to offer.<br />

4


Editorial Comment<br />

The Energy Management, Lighting, Medical, and Hybrid/Electric<br />

Auto markets are quickly gaining scale and are directly driving an<br />

explosion of microcontroller usage. As microcontroller designs<br />

expand into new areas, so do the connectivity requirements, which is<br />

the theme of this issue of <strong>TechZone</strong> <strong>Magazine</strong>.<br />

In this issue, we explore all facets of <strong>Microcontroller</strong> connectivity<br />

protocols and how to overcome typical technical roadblocks. You<br />

will fi nd a strong selection of articles to support your connectivity<br />

protocol design decisions including:<br />

• “uIP TCP/IP Protocol Stack Demonstration” – a step by step<br />

guide using Ethernet connectivity with the titled protocol stack<br />

contributed by Renesas (page 22)<br />

• “Introducing a Second MCU to Embedded Designs” – an article on overcoming the<br />

common pitfalls of adding a second MCU to your design written by Nicholas Cravotta<br />

(page 15)<br />

• “The Ultra-Low-Power USB Revolution” – an article on integrated USB connectivity<br />

written by a trio of authors from Texas Instruments (page 7)<br />

If your design is integrated into a Lighting, Wireless or Sensor solution, see our recent<br />

<strong>TechZone</strong> magazines focusing on those areas at www.digikey.ca/magazine.<br />

When the design is complete and it’s time to build your product, remember that Digi-Key:<br />

• Stocks over 565,000 components available for off-the-shelf delivery anywhere in the world<br />

• Ships 99% of orders received by 8pm central time the same day<br />

• Offers world-class supply chain support and customer service<br />

While it’s unclear how the political uncertainty in the Middle East will affect the global<br />

economy; it is very clear that microcontrollers will continue to pervasively expand into<br />

products that touch our everyday lives. We believe that the information and insights in this<br />

issue of <strong>TechZone</strong> <strong>Magazine</strong> will support your next generation product ideas and solutions.<br />

Sincerely,<br />

Mark Zack<br />

Vice President, Semiconductor Product<br />

Digi-Key Corporation<br />

Mark Zack<br />

Vice President, Semiconductor<br />

About Digi-Key Corporation<br />

As one of the world’s fastest growing<br />

distributors of electronic components,<br />

Digi-Key Corporation has earned its<br />

reputation as an industry leader through<br />

its total commitment to service and<br />

performance. As a full-service provider<br />

of both prototype/design and production<br />

quantities of electronic components,<br />

Digi-Key has been ranked #1 for Overall<br />

Performance for 19 consecutive years<br />

from among the nation’s more than 200<br />

distributors (EE Times Distribution Study/<br />

October 2010). Offering more than 1.9<br />

million products from more than 470<br />

quality name-brand manufacturers,<br />

Digi-Key’s commitment to inventory is<br />

unparalleled. Access to the company’s<br />

broad product offering is available 24/7<br />

at Digi-Key’s top-rated website.<br />

www.digikey.ca<br />

Digi-Key’s <strong>TechZone</strong> <strong>Magazine</strong> is a monthly<br />

series of technology-specifi c publications<br />

featuring information and resources for Lighting,<br />

<strong>Microcontroller</strong>s, Wireless, and Sensors, with<br />

more technologies to come. <strong>TechZone</strong><br />

<strong>Magazine</strong><br />

provides the engineering community,<br />

from students to professional design engineers,<br />

with information about supplier innovations,<br />

quality in-depth solutions, and a selection of<br />

application-specifi c considerations focused on<br />

advancing technology.<br />

Contact Information<br />

For questions, comments, or to submit an article:<br />

tzcontent@digikey.com<br />

For information about advertising oppotunities:<br />

techzoneadvertising@digikey.com<br />

To be added to the mailing list:<br />

www.digikey.ca/request<br />

Copyrights: The masthead, logo, design, articles, content and format of<br />

<strong>TechZone</strong> are Copyright <strong>2011</strong>, Digi-Key Corporation. All rights are reserved.<br />

No portion of this publication may be reproduced in part or in whole without<br />

express permission, in writing, from Digi-Key.<br />

Trademarks: DIGI-KEY, the Digi-Key logo, TECHZONE, and the <strong>TechZone</strong> logo<br />

are trademarks of Digi-Key Corporation. All other trademarks, service marks or<br />

product names are the property of their respective holders.<br />

All product names, descriptions, specifi cations, prices and other information<br />

are subject to change without notice. While the information contained in this<br />

magazine is believed to be accurate, Digi-Key takes no responsibility for<br />

incorrect, false or misleading information, errors or omissions. Your use of<br />

the information in this magazine is at your own risk. Some portions of the<br />

magazine may offer information regarding a particular design or application<br />

of a product from a variety of sources; such information is intended only as a<br />

starting point for further investigation by you as to its suitability and availability<br />

for your particular circumstances and should not be relied upon in the absence<br />

of your own independent investigation and review. Everything in this magazine<br />

is provided to you “AS IS.” Digi-Key expressly disclaim any express or implied<br />

warranty, including any warranty of fi tness for a particular purpose or noninfringement.<br />

Digi-Key cannot guarantee and does not promise any specifi c<br />

results from use of any information contained in this magazine. Any comments<br />

may be addressed to techzone@digikey.com.<br />

www.digikey.ca/microcontroller<br />

5


<strong>Microcontroller</strong> <strong>TechZone</strong> SM Q & A<br />

In the rapidly evolving microcontroller market, it seems as if there is something new every day – technologies, products,<br />

consumer trends, or regulations. Time-to-market demands have never been greater with the design of many of today’s<br />

new microcontroller products requiring expertise in more than one discipline.<br />

You have questions. We have answers. On target to field more than 260,000 calls this year, our technical support<br />

specialists are available 24/7/365 to answer your questions and assist you with your microcontroller needs.<br />

If you have a question, we invite you to contact our technical staff via telephone, live web chat, or by emailing your<br />

question to techzone@digikey.com.<br />

How does USB 3.0 differ from USB 2.0<br />

USB 3.0 offers a “SuperSpeed” bus feature. USB 3.0 cables have<br />

two wires for power and ground, two wires for “non-SuperSpeed”<br />

data, four additional wires for the “SuperSpeed” data, and a shield<br />

which was not needed in other USB versions. The “SuperSpeed” bus<br />

offers a forth transfer mode at 5.0 Gbits/s. The physical form factor<br />

has changed for the USB 3.0 plugs and receptacles to accommodate<br />

the additional pins for the “SuperSpeed” mode. The standard-A<br />

plugs are extended as well as the receptacles are deeper. For the<br />

Standard-B connectors, the “SuperSpeed” contacts are placed on<br />

top of the existing connector. A legacy standard A to B cable will<br />

work normally in these connectors as the legacy connectors will not<br />

make contact with the new contacts for the “SuperSpeed.”<br />

This ensures backwards compatibility. On the fl ip side, though, the<br />

USB 3.0 connector will not mate to the legacy receptacles.<br />

What are the common applications for CAN (Controller<br />

Area Network)<br />

CAN was fi rst developed with automotive applications in mind.<br />

An example of this is in-vehicle electronic networking. However,<br />

since its development CAN has been utilized in medical, industrial<br />

and commercial applications. Examples of medical applications<br />

include operating room components such as lights, tables, cameras,<br />

patient beds and X-ray machines. Industrial application examples<br />

include motor control and robotics. Finally, commercial application<br />

examples include lab equipment, telescopes, and automatic doors.<br />

How is an SPI master/slave connection set up<br />

SPI is a protocol on four signal lines. A clock signal (SCLK) is sent<br />

from the bus master to all slaves. A slave select signal for each slave,<br />

SSn, is used to select the slave the master communicates with. A<br />

data line from the master to the slaves called MOSI (Master Out-Slave<br />

In) and a fi nal data line from the slaves to the master called MISO<br />

(Master In-Slave Out) comprise the other two signal lines.<br />

What is the difference between a UART and USART<br />

A UART is a universal asynchronous receiver/transmitter where a<br />

USART can communicate synchronously as well as asynchronously.<br />

Does the operating ambient temperature include the selfheating<br />

of the MCU<br />

The operating ambient temperature is the ambient temperature in a<br />

state without MCU self-heating. More specifi cally, consider it to be<br />

the temperature of the surroundings infi nitely close to the package<br />

surface when the MCU is not powered on.<br />

What does it mean if a microcontroller supports big endian<br />

or little endian, what does endian mean<br />

The term “endian” refers to how individually addressable subcomponents<br />

are ordered within a longer data item stored in memory.<br />

Let’s say we had a block of memory that had ABCD stored, four bytes.<br />

For the big-endian method, the most signifi cant byte value, which is A in<br />

our example, is stored at the memory location with the lowest address,<br />

0x00, the next byte value, B, would be stored at the following memory<br />

location, 0x01, and so on. For the little-endian method, the least<br />

signifi cant byte value, D, is stored at the lowest address, 0x00, the next<br />

signifi cant byte, C, in the following memory location, 0x01, and so on.<br />

What is the difference between SPI and I 2 C<br />

SPI uses four logic signals commonly called: SCLK (Serial Clock),<br />

MOSI (Master Output, Slave Input), MISO (Master Input, Slave<br />

Output) and SS (Slave Select). While I 2 C uses only two bi-directional<br />

open-drain lines commonly called: SDA (Serial Data Line) and SCL<br />

(Serial Clock). Additionally, to add additional slaves, SPI will end up<br />

being more than four signal lines, where I 2 C will stay with the same<br />

two lines. In relation to speed, SPI is a higher speed protocol, over<br />

10 Mbps. I 2 C is limited to data rates that are chosen between 100<br />

kbps, 400 kbps or 3.4 Mbps.<br />

Do you have a question about<br />

microcontroller solutions<br />

Digi-Key has more than 130 technical support<br />

specialists, product managers, and applications<br />

engineers who are eager to answer your questions<br />

and assist you with your microcontroller projects.<br />

Send your questions to techzone@digikey.com.<br />

6


The Ultra-Low-Power<br />

USB Revolution<br />

by Bhargavi Nisarga, Keith Quiring, and Les Taylor, Texas Instruments<br />

New MCUs bring power efficiency and<br />

simplicity to USB for portable embedded<br />

applications.<br />

The ubiquity of USB makes it an extremely attractive interface for<br />

applications requiring connectivity to a PC or other host device for<br />

configuration, periodic downloading of data, or firmware updates.<br />

Often these devices are portable, such as medical or industrial tools<br />

which remotely collect data that needs to be uploaded at a later time.<br />

As these devices are portable, the final USB implementation must be<br />

both cost-effective and power efficient.<br />

One of the main reasons for USB’s success is its unparalleled ease<br />

of use. But under the surface, USB is a complicated technology that<br />

artfully masks the user from the complexity. As a result, developers<br />

new to USB often underestimate the effort involved. Many new terms<br />

and procedures are also encountered, and things often do not “just<br />

work” the way they should.<br />

Hidden challenges may result in unexpected delays for the developer,<br />

and delays are expensive.<br />

To developers trying to focus on differentiating their products and<br />

offering the best value to their customers, these challenges are an<br />

unwelcome burden. For this reason, TI has committed to delivering<br />

USB technology as an integrated, simplified solution that enables<br />

developers to focus on using USB in their application rather than<br />

learning USB as a technology.<br />

Introducing the MSP430TM USB microcontroller<br />

To meet the needs of developers, TI has introduced full-speed USB to<br />

the F5xx series of MSP430 microcontrollers (MCU). By integrating USB<br />

with powerful performance (up to 25 MHz), large memory (both Flash<br />

and RAM), integrated intelligent peripherals (including an on-chip<br />

ADC, comparator, hardware multiplier, DMA controller, temperature<br />

sensor and other peripherals), and superior power management,<br />

the MSP430 is the ideal MCU for implementing USB in embedded<br />

applications (see Figure 1).<br />

With the simple addition of a USB connector and a few discretes,<br />

MSP430 USB MCUs are a complete solution for applications that<br />

require USB connectivity and analog peripherals, while being<br />

ultra-low-power. From a software standpoint, TI provides API stacks<br />

supporting three of the most common device classes.<br />

Figure 1: Integrating USB with the powerful performance and high integration of<br />

the MSP430 architecture creates the ideal microcontroller for implementing USB in<br />

embedded applications.<br />

The new MSP430 USB MCUs are based on TI’s newest and most<br />

advanced MSP430 architecture, the F5xx. Each supports 1.8 to<br />

3.6 V operation, with clock speeds up to 25 MHz and integrated,<br />

programmable power supervision on the order of 200 nA. New clock<br />

sources further maximize tradeoffs between power, speed, precision<br />

and cost. Flash writes/erases can be performed across the full range<br />

of Vcc. In addition to offering a wide range of flash memory sizes (64<br />

to 128 KB and 16 to 256 KB), USB-enabled MSP430 devices also have<br />

2 KB RAM dedicated to USB that, when USB is disabled, is available<br />

for general purpose use.<br />

Accelerated development and ease of use<br />

TI recognizes that consumers – and engineers – have come to<br />

expect that USB “just works.” In truth, while USB looks as simple<br />

as a UART or SPI port, the protocol is not trivial to implement.<br />

And unlike the UART or SPI interfaces, compliance is a primary<br />

USB design consideration, even in the simplest applications. For<br />

example, a host can suspend an attached device at any time.<br />

Devices must also be able to handle “surprise removals.” For<br />

developers who have not been through this process before, such<br />

unexpected considerations can require extra development time and<br />

lead to unexpected delays.<br />

Part of the value-add of the MSP430’s USB support is that much<br />

of the underlying complexity of implementing USB is managed<br />

through an intuitive API stack. The API stacks are designed for fast<br />

absorption by the developer. Like USB itself, they contain much<br />

of the complexity “under the hood,” masking the developer from<br />

unnecessary hassle to help speed development time. The stack<br />

www.digikey.ca/microcontroller<br />

7


source code is open for those developers wishing for complete<br />

control. For each stack, a complete Programmer’s Guide is provided<br />

that serves as a reference for the API function calls and also<br />

describes the underlying concepts with clarity.<br />

Further, TI provides the MSP430 USB Descriptor Tool. This tool<br />

serves as a “control panel” for the API stacks, allowing for quick<br />

confi guration. It automatically creates the descriptors that every USB<br />

device must report to the host, based on user input. This saves the<br />

developer considerable time and provides peace of mind that the<br />

descriptors are done correctly.<br />

Stacks are available for the most common device classes and are<br />

supplied without additional charge. While developers should not<br />

underestimate what is required to create a robust USB interface,<br />

TI has signifi cantly shortened the USB learning curve. In this way,<br />

developers are freed of much of the burden of learning the intimate<br />

details of USB as a technology and instead are able to focus on using<br />

USB to increase the value and usability of their applications.<br />

Multiple device classes<br />

Part of the simplicity offered by the MSP430 USB API Stack is support<br />

for three device classes:<br />

Communications Device Class (CDC): The CDC presents the<br />

USB port to the PC application as a standard COM port. COM ports<br />

are popular interfaces that are fl exible, fast, and simple to use.<br />

Because it uses bulk transfers, the CDC provides high bandwidth<br />

with a reasonable amount of simplicity. The chief disadvantage of<br />

using the CDC is that developers must distribute a simple fi le to<br />

end users that allows it to be associated with the CDC driver built<br />

into Windows. Fortunately, the “new device detected” installation in<br />

Windows is fairly straightforward and a minor step already wellaccepted<br />

by end-users.<br />

Human Interface Device (HID): While HID is commonly thought of as<br />

primarily for mice and keyboards, it is a fl exible device class suitable<br />

for a wide variety of applications. TI’s HID API effi ciently generalizes<br />

HID capabilities, thereby eliminating the complexity associated with<br />

HID reports by allowing developers to access the interface in the<br />

exact same way they would a CDC device/COM port. While it has<br />

limited bandwidth (up to 64 KB/s), it requires no fi le to be distributed<br />

as CDC does, and it loads silently in Windows with no installation<br />

process required.<br />

Mass Storage Class (MSC): MSC is the device class used to<br />

implement the highly successful USB “fl ash drives,” as well as<br />

digital cameras and fl ash card readers. Since it is designed for<br />

moving large amounts of data, it provides higher bandwidth, similar<br />

to that of CDC. The tradeoff is more complexity – for example,<br />

developers will need to implement a fi le system – and the use of<br />

more code space. Like HID, MSC devices load silently in Windows<br />

without the need of an installation process. TI offers the MSC API<br />

layer at no cost. Given the wide variety of confi guration possibilities<br />

for software handling fi le systems, the different media types,<br />

and Flash management (i.e., through wear-leveling and other<br />

techniques), developers have the fl exibility of buying a commercial<br />

implementation or using one of the many open-source systems<br />

available for the MSP430.<br />

Of the three device classes, developers should begin by considering<br />

HID. If an application can work within the available 64 KB/s<br />

bandwidth, HID will often be the most cost-effective choice given<br />

that users can plug it in and use it without the need of an installation.<br />

Since the Windows installation process can sometimes lead to<br />

problems for the user, avoiding it can lead to a reduction of support<br />

calls and returns from customers.<br />

The TI USB API stacks support three data transfer types: control<br />

for USB-level control/status data, interrupt for low bandwidth,<br />

fi xed latency data, and bulk for high bandwidth, variable latency<br />

data. Usage of these data types is determined by the device class;<br />

developers need not concern themselves with most of the details<br />

associated with the different types.<br />

With these data types, the MSP430’s USB can support any application<br />

requiring control/confi guration, fi rmware updating, or that needs to<br />

transfer bulk data (as opposed to streaming data). The MSP430 does<br />

not support isochronous (high-bandwidth, fi xed latency) data, so it is<br />

not appropriate for streaming audio/video applications.<br />

Just as the MSP430 is fl exible, so is its USB functionality. Any USB<br />

device contains a certain number of what are called endpoints.<br />

Support for multiple endpoints allows for composite USB devices<br />

which can have more fl exible communication with hosts. For example,<br />

a device that uses the MSC for bulk data transfers and HID to manage<br />

control and status is comprised of three input and three output<br />

endpoints. The MSP430 architecture supports up to eight input and<br />

eight output endpoints, which provides suffi cient capacity for most<br />

applications without overburdening cost.<br />

Ultra-low-power efficiency<br />

By its nature, the MSP430 architecture has been optimized for<br />

low- power operation, both when USB is in use and when it is not. For<br />

example, MSP430 devices have fi ve low-power modes that enable<br />

designers to extend battery life in portable applications. The MSP430<br />

delivers high performance at the lowest power consumption with<br />

an active power consumption as low as 160 µA/MHz and 1.5 µA in<br />

standby mode coupled with fast wakeup from standby (less than<br />

5 microseconds) and a supply voltage as low as 1.8 V operation.<br />

The onboard DMA controller can also save signifi cant power when<br />

communicating with a battery-powered host.<br />

One of the advantages of USB in embedded applications is the<br />

ability to power devices over the interface. Ideally, battery-powered<br />

devices can maximize operating life by powering the device over<br />

the bus when attached to a host. As USB hosts source 5 V over the<br />

bus, an LDO is required to drop the voltage to the 3.3 V typical of ICs.<br />

MSP430 devices simplify power design and conserve board space by<br />

integrating an effi cient LDO as well as associated pull-up functionality.<br />

In addition to allowing MSP430s to operate directly from 5 V,<br />

integrating the LDO and pull-up resistors reduces component count<br />

and eliminates $.15 to $.20 relative to discrete implementations.<br />

By keeping the USB power and other MSP430 modules’ power<br />

management separate, the USB module can always be powered as<br />

long as the USB device is connected to the host. This also enables the<br />

USB module to auto-powerup the MSP430 via USB power even if the<br />

device battery is dead or non-existent.<br />

8


Figure 2: MSP430 USB microcontrollers can source power off the USB bus to power<br />

the entire system with 12 mA.<br />

MSP430s are designed to operate within the power limits of the<br />

LDO and can even source power off the USB bus to power the entire<br />

system. By driving the 3.3 V output externally (VUSB), the MSP430 can<br />

supply the system with up to 12 mA (see Figure 2), and eliminate the<br />

need for a system LDO as well. For high-current systems (requiring<br />

more than 12 mA of current) or for applications where it makes sense<br />

to power a device from battery even when connected via USB, the<br />

MSP430 offers the flexibility of bypassing the integrated LDO and<br />

driving DVcc from an external supply or regulator (see Figure 3). TI<br />

offers a variety of external LDOs well-suited for low-cost (TPS73033),<br />

low-power (TPS67233), low-noise (TPS1733), and low-noise, highercurrent<br />

(TPS73433/735) applications.<br />

Figure 3: For high-current systems or for applications where it makes sense to power a<br />

device from battery even when connected via USB, the MSP430 offers the flexibility of<br />

bypassing the integrated 3.3 V LDO and driving DVcc from an external supply.<br />

The 5 V USB bus power can also be used as a primary source to<br />

charge batteries (see Figure 4). In this configuration, DVcc is always<br />

sourced from the battery whether the USB port is plugged into a host<br />

or not. When the port is plugged in, the charger receives power via<br />

USB to recharge the battery. TI’s BQ2407x/3x family of chargers have<br />

been specifically designed for USB battery charging applications.<br />

Figure 4: Power over USB can also be used as a primary source to charge batteries.<br />

TI’s BQ2407x/3x family of chargers has been specifically designed for USB battery<br />

charging applications.<br />

The low-speed USB used in mice and keyboards, for example, in<br />

general is not appropriate for any application processing enough<br />

data that it requires a modern, general-purpose MCU. Specifically,<br />

transmitting at a slower data rate wastes bus bandwidth and<br />

consumes more power by requiring the MCU to stay active for<br />

significantly longer transmission periods. Likewise, high-speed USB<br />

supplies too much bandwidth unless an application needs to support<br />

large audio or video transfers. Full-speed USB is a much better fit for<br />

most embedded applications.<br />

While being an OTG appears to be an appealing option, it is not<br />

appropriate for many applications. Embedded hosts must be able<br />

to source 8 mA to attached devices. This requirement has led many<br />

companies to reconsider their intention to support OTG host capability,<br />

especially in applications where long operation life is required from<br />

a single-cell battery. For applications that do require OTG support, TI<br />

offers solutions within its Stellaris MCU portfolio.<br />

In general, USB devices are less expensive, simpler, and faster to<br />

develop than embedded hosts. The MSP430 family with USB was<br />

optimized to meet the needs of USB devices without burdening these<br />

applications with the added complexity, additional memory, integrated<br />

peripherals and larger power supplies required to implement USB hosts.<br />

Taking care of details<br />

In order to deliver on its promise to simplify USB, TI provides a wide<br />

range of tools and software to assist developers in quickly coming up<br />

to speed on using and implementing robust USB solutions. In addition<br />

to its API stack, TI also offers:<br />

• USB Descriptor Tool: The USB Descriptor Tool plays a key role<br />

in simplifying USB design and implementation. This GUI-based<br />

tool automatically configures the USB stack to reflect the<br />

specific requirements of a particular application, handling the<br />

management of descriptor fields including VID, PID, strings,<br />

how much power to draw from the host, and so on. Rather than<br />

require developers to delve into the details behind the various<br />

USB descriptor fields by breaking into the USB stack and writing<br />

code to support their application, the Descriptor Tool gathers<br />

the required information from developers and automatically<br />

generates the appropriate software modifications to the API<br />

stacks, requiring no further work from developers. In addition,<br />

the USB Descriptor Tool is intended to make the high-level stack<br />

configuration of composite devices much simpler.<br />

• Bootstrap Loader (BSL): TI’s BSL is another important tool<br />

offered to developers who require field firmware update<br />

capability. One of the common uses of USB is to push updates<br />

to deployed devices. For example, a doctor could plug a medical<br />

instrument into a PC and have it quickly and automatically update<br />

itself with new features or bug fixes. The BSL tool simplifies the<br />

updating process for developers by converting a firmware image<br />

file into a self-contained PC executable that can be delivered to<br />

end customers. All MSP430 devices are BSL-equipped and when<br />

implemented over USB, updates can be made securely even when<br />

the device is not powered (i.e., the MSP430 is powered via USB),<br />

enabling fast and efficient production-line programming without<br />

having to install batteries. For developers, the most complex<br />

part of the bootstrapping process will be to customize the BSL<br />

executable with their own logo.<br />

www.digikey.ca/microcontroller<br />

9


• haring Program TI also offers developers the opportunity<br />

to participate in its VID Sharing Program. Every USB device<br />

requires a Vendor_ID (VID) and Product_ID (PID). For companies<br />

making only a few devices, TI can provide a VID and a unique PID<br />

to bypass the investment of time and money required to register<br />

a VID with the USB consortium.<br />

By taking care of the “odds and ends” of implementing USB<br />

through the USB Descriptor Tool, Bootstrap Loader, API stack, and<br />

other support software from its extensive third party network,<br />

TI has simplified the process of working with USB. By providing<br />

most of the underlying foundation required for USB, TI’s MSP430<br />

enables developers to focus on the value-added components of<br />

their application without having to concern themselves with the<br />

myriad implementation issues involved with a complex interface<br />

like USB.<br />

igh level of integration<br />

In addition to integrating USB, these new controllers also integrate<br />

a number of other features and peripherals beyond the standard<br />

MSP430 architecture that further simplify development, including:<br />

• Programmale P This fl exible, programmable PLL can<br />

adapt to a wide range of crystal frequencies, enabling<br />

developers to choose a frequency based on applicationrelevant<br />

criteria such as cost, other components within the<br />

system, or whether that frequency is needed elsewhere in the<br />

system for another purpose.<br />

• er opoer scillator The VLO enables developers<br />

to keep the USB module running when the host is suspended.<br />

This is important because the USB module must be able to<br />

recognize when the host wants to wake it. Current drawn by the<br />

VLO in this manner is in the sub-µA range.<br />

• omparator MSP430 USB microcontrollers also offer a new<br />

comparator for the generation of hysteresis without the need<br />

for external components. Many applications require the ability<br />

to monitor an input against two thresholds, such as for battery<br />

charging and capacitive touch interfaces. Typical comparators<br />

can only monitor one threshold and must be confi gured to<br />

watch for the rising or falling threshold and switch to the other<br />

threshold when it is crossed. Known as Comparator_B, the new<br />

comparator is a versatile reference generator using R-ladders<br />

capable of generating 32 different voltage reference levels.<br />

This approach avoids the need for external components as well<br />

as the constant power drain when external resistors are used.<br />

Comparator_B operates in three modes, ultra-low-power (0.1 µA<br />

typical to 0.5 µA max.), normal (10 µA typical to 30 µA max.), and<br />

high-speed (40 µA typical to 65 µA max.) for optimizing power<br />

consumption to the application.<br />

• Port Mapping A unique feature of USB-based MSP430<br />

microcontrollers is the port mapping controller. With port<br />

mapping, developers can dynamically reconfi gure digital outputs<br />

such as Timer PWMs or SPI/I2C interfaces across a specifi c<br />

range of pins. Such mapping enables fl exibility of signal routing<br />

during board design, allowing designers to move signals to<br />

the other side of the IC as required. Each digital output can be<br />

mapped to multiple output pins, which can be useful in cases,<br />

for example, where the same Timer PWM is required on multiple<br />

pins. Port mapping also eases the challenges associated with<br />

migrating from one family of devices to another in terms of<br />

pin-to-pin compatibility.<br />

etting started ith <br />

Getting started MSP430 USB microcontrollers is very easy. The<br />

MSP430F552x Sample Kit includes the 80-pin MSP-TS430 target<br />

board (#MSP-TS430PN80-USB) complete with USB support as well<br />

as sample silicon. With the proven tool chain of the MSP430 and the<br />

comprehensive USB support package, developers already familiar<br />

with the MSP430 can introduce USB to their applications with<br />

little effort. In addition, TI’s many third parties supply a wide range<br />

of software and hardware to speed development and accelerate<br />

time-to-market.<br />

Developers can choose from three families of USB-enabled MSP430<br />

microcontrollers, each with a fl exible roadmap and options that scale<br />

to meet a variety of embedded application requirements:<br />

• Midrange applications The F552x / F551x supplies 64<br />

to 128 KB Flash and 4 to 8 KB (+2 KB) RAM, as well as<br />

Comparator_B functionality. F552x \ F551x devices are<br />

sampling now.<br />

• ighend applications The F563x/F663x is perhaps the most<br />

feature-rich, integrated MSP430 device ever produced. With<br />

128 to 256 KB Flash and 16 KB (+2 KB) RAM, this device has<br />

six DMA channels, an RTC backup mode (enabling the RTC to<br />

operate at less than 1 µA even when Vcc is lost), and many<br />

other integrated peripherals.<br />

• oend applications The F550x provides cost-effective USB<br />

with 16 to 32 KB Flash and 4 KB + 2KB RAM as well as a 10-bit<br />

ADC and Comparator_B functionality.<br />

TI’s new MSP430 USB microcontrollers reduce system cost,<br />

offer superior power effi ciency to improve battery life, facilitate<br />

fast implementation, and are easy to use. In addition to allowing<br />

developers to focus on their application rather than USB as an<br />

enabling technology, these new controllers also lower system<br />

BOM by integrating several advanced peripherals and modules<br />

that increase performance and improve power consumption while<br />

reducing component count. With its comprehensive supporting<br />

software and hardware, TI reduces the USB learning curve from<br />

weeks to hours, making it cost-effective – and simple – to<br />

introduce USB into a wide range of embedded applications.<br />

Tools http://www.ti.com/msp430tools<br />

ptodate documentation, product information, and softare<br />

lins http://focus.ti.com/docs/prod/folders/print/msp430f5529.html<br />

Tale Device class tradeoffs.<br />

es es M es<br />

Simplicity on host Yes Yes No<br />

Simplicity on MSP430 Yes Yes No<br />

Avoids user install process No Yes Yes<br />

High bandwidth Yes No, 64 KB/s Yes<br />

Code size 4 KB 4 KB 10 to 20 KB<br />

10


MSP430x5xx Overivew<br />

Texas Instruments<br />

The MSP430x5xx MCU from Texas Instruments is the next<br />

generation technology platform for the MSP430 series<br />

of MCUs. The device features advanced ultra-low-power<br />

technology, signifi cantly higher levels of integration,<br />

and is designed<br />

for customer<br />

ease-of-use.<br />

The product training<br />

module for this<br />

product allows<br />

viewers to learn more<br />

about the product<br />

line’s features and<br />

the device’s capability for easy migration. Direction to TI’s<br />

collection of over 1,000 code examples and more than 100<br />

application reports is included<br />

in this product training module.<br />

www.digikey.ca/ptm<br />

MSP-EXP430F5438 Experimenter Board (MSP-EXP430F5438)<br />

The MSP430F5438 Experimenter Board (MSP-EXP430F5438)<br />

is a development platform for the latest generation of<br />

MSP430 MCUs. It features a 100-pin socket that supports<br />

the MSP430F5438 and other devices with similar pinout.<br />

The socket allows for quick upgrades to newer devices<br />

or quick applications changes. It is compatible with many<br />

TI low-power RF wireless evaluation modules such as the<br />

CC2520EMK. The Experimenter Board helps designers<br />

quickly learn and develop<br />

using the new F5xx MCUs,<br />

which provide the industry’s<br />

lowest active power<br />

consumption, more memory<br />

and leading integration<br />

for applications such<br />

as energy harvesting,<br />

wireless sensing and<br />

automatic metering<br />

infrastructure (AMI).<br />

www.devtoolsxpress.com<br />

www.digikey.ca/texasinstruments-mcu<br />

www.digikey.ca/microcontroller<br />

11


USB-Based<br />

Temperature Monitor<br />

contributed by Analog Devices<br />

Using an analog MCU, an LDO, an external thermistor, and a few discretes, you can construct a<br />

highly accurate temperature sensing application.<br />

Figure 1: ADuC7122 used as a temperature monitor interfaced to a thermistor (simplifi ed schematic, all connections not shown).<br />

The circuit in Figure 1 shows how the ADuC7122 precision analog<br />

microcontroller can be used in an accurate thermistor temperature<br />

monitoring application. The ADuC7122 integrates a multichannel<br />

12-bit SAR ADC, twelve 12-bit DACs, a 1.2 V internal reference,<br />

as well as an ARM7 core, 126 kB flash, 8 kB SRAM, and various<br />

digital peripherals, such as UART, timers, SPI, and two I2C<br />

interfaces. The ADuC7122 is connected to a 4.7 kΩ thermistor.<br />

Due to the small form factor of the ADuC7122 (7 mm × 7 mm,<br />

108-ball BGA package) the entire circuit will fit on an extremely<br />

small PCB, thus further reducing cost.<br />

Similar in function to an RTD, thermistors are low-cost,<br />

temperature-sensitive resistors and are constructed of solid<br />

semiconductor materials, which exhibit a positive or negative<br />

temperature coefficient. Thermistors are inexpensive and have<br />

high sensitivity. They detect small variations in temperature,<br />

which could not be observed with an RTD or a thermocouple.<br />

However, thermistors are highly nonlinear; thus, they are limited to<br />

applications with very narrow temperature ranges if linearization<br />

techniques are not applied. Circuit linearization techniques can be<br />

accomplished in software.<br />

Despite the powerful ARM7 core and high-speed SAR ADCs,<br />

the ADuC7122 still provides a low-power solution. With the<br />

ARM7 core running at 326.4 kHz and the primary ADC active<br />

and measuring the external<br />

temperature sensor, the entire<br />

circuit typically consumes 7<br />

mA. Between temperature<br />

measurements, the ADC and/<br />

or the microcontroller can<br />

be switched off to further<br />

minimize power consumption.<br />

Circuit description<br />

The circuit shown in Figure 1 is<br />

powered entirely from the USB<br />

interface. The 5 V supply from the<br />

USB is regulated to 3.3 V using<br />

the ADP3333 (3.3V) low-dropout<br />

linear regulator. The regulated<br />

3.3 V supplies the DVDD voltage to the ADuC7122. The AVDD supply to<br />

the ADuC7122 has additional fi ltering as shown. A fi lter is also placed<br />

on the USB supply at the input of the linear regulator.<br />

The following features of the ADuC7122 are used in this application:<br />

• 12-bit SAR ADC.<br />

• ARM7TDMI core: The powerful 16-/32-bit ARM7 core with<br />

integrated 126 kB fl ash and SRAM memory, runs the user<br />

code that confi gures and controls the ADC, processes the<br />

ADC conversions from the thermistor sensor, and controls the<br />

communications over the UART/USB interface.<br />

• UART: The UART is used as the communication interface to the<br />

host PC.<br />

• Two external switches/buttons (not shown) are used to force the part<br />

into its flash boot mode. By holding DOWNLOAD low and toggling the<br />

RESET switch, the ADuC7122 will enter boot mode instead of normal<br />

user mode. In boot mode, the internal flash may be reprogrammed<br />

through the I2CWSD tool utilizing the USB interface.<br />

• BUF_VREF: The band gap reference also connects through<br />

buffers to the BUF_VREF1 and the BUF_VREF2 pins, which<br />

can be used as a reference for other circuits in the system. A<br />

minimum of 0.1 µF capacitor should be connected to these pins<br />

to reduce noise.<br />

12


The thermistor used in the circuit is a 4.7 kΩ resistor, model number<br />

NCP18XM472. It is available in a 0603 surface-mount package.<br />

The thermistor used in the circuit in Figure 2 has the following<br />

specifi cations at 25°C: ß = 3500 (the ß parameter describes resistance<br />

as a function of temperature) and resistance (R 25<br />

) = 4.7 kΩ.<br />

The USB interface to the ADuC7122 is implemented with an FT232R<br />

UART to USB transceiver, which converts USB signals directly to the<br />

UART protocol.<br />

In addition to the decoupling shown in Figure 1, the USB cable itself<br />

should have a ferrite for added EMI/RFI protection. The ferrite beads<br />

used in the circuit are Taiyo Yuden, BK2125HS102-T, which have an<br />

impedance of 1,000 Ω at 100 MHz.<br />

The circuit must be constructed on a multilayer PC board with a<br />

large area ground plane. Proper layout, grounding, and decoupling<br />

techniques must be used to achieve optimum performance.<br />

Figure 2: A simple temperature sensor<br />

circuit implemented with the ADuC7122.<br />

The input thermistor circuit<br />

in Figure 2 is designed to<br />

produce accurate temperature<br />

measurements from 0°C to<br />

90°C. Note that this system<br />

contains no temperature<br />

calibration. This circuit<br />

contains a simple thermistor<br />

circuit that does not contain<br />

circuit linearization. If this<br />

circuit employed linearization<br />

techniques, it could function over a broader range of temperatures;<br />

however, this would decrease the resolution of the sensor.<br />

The circuit in Figure 2 is set up in a voltage divider confi guration. This<br />

will allow us to transform the ADC result, D, into a measurement of<br />

the resistance of RTH (thermistor) using the following formulas:<br />

<br />

= ∗ (<br />

( + ) )<br />

Figure 3: ADuC7122 thermistor sensor measured output (converted to volts) with ADC0<br />

versus temperature.<br />

Figure 3 plots the response of the ADuC7122 to the thermistor sensor<br />

detailed in Figure 2 over temperature.<br />

Code description<br />

The source code and a HyperTerminal confi guration fi le used to test<br />

the attached circuit can be downloaded as a zip fi le at www.analog.<br />

com/CN0153_Source_Code.<br />

The UART is confi gured for a baud rate of 9600, 8 data bits, no parity<br />

and no fl ow control. If the circuit is connected directly to a PC, a<br />

communication port viewing application such as HyperTerminal can<br />

be used to view the results sent by the program to the UART (Figure<br />

4). The source code is commented to make it easier to understand<br />

and manipulate. The code was compiled and tested using the Keil<br />

µVision 3 application.<br />

= 2 ∗ ( <br />

)<br />

<br />

<br />

= ∗ (<br />

= ∗ (( 2<br />

+ 1) ) )<br />

= 2 ∗ ( <br />

)<br />

<br />

Once the resistance of the thermistor is calculated, the Steinhart-Hart<br />

equation can be used to determine the ( 1<br />

current ∗ ) temperature of the sensor.<br />

= ∗ (<br />

Using the following formula, the<br />

(<br />

ADuC7122 <br />

2<br />

25<br />

<br />

)<br />

1)<br />

is able to determine the<br />

<br />

sensor temperature:<br />

2 =<br />

<br />

( 25 <br />

)<br />

( 1 ∗ )<br />

( 25 <br />

)<br />

2 =<br />

<br />

( 25 <br />

)<br />

where:<br />

T 2<br />

= unknown temperature<br />

V 1<br />

= 298K<br />

ß = ß parameter of the thermistor @ 298K or 25°C. ß = 3500<br />

R 25<br />

= resistance of thermistor @ 298K or 25°C. R25 = 4.7 kΩ<br />

R TH<br />

= resistance of thermistor @ unknown temperature as<br />

calculated by formula above<br />

Figure 4: Output of HyperTerminal communication port viewing application.<br />

Common variations<br />

The ADP3333 (3.3 V) can be replaced with the ADP120 (2.5 V),<br />

which has a wider operating temperature range (−40°C to +125°C)<br />

and consumes less power (typically 20 μA versus 70 μA) but has a<br />

lower maximum input voltage range (5.5 V versus 12 V). Note that<br />

the ADuC7122 can be programmed or debugged using a standard<br />

JTAG interface. For a standard UART to RS-232 interface, the FT232R<br />

transceiver can be replaced with a device such as the ADM3202,<br />

which requires a 3 V power supply.<br />

The thermistor circuit described here can be adapted to operate with<br />

other precision analog microcontrollers, such as the ADuC7020 series,<br />

the ADuC7023, and the ADuC7061 series.<br />

www.digikey.ca/microcontroller<br />

13


ARM7 Core MicroConverter<br />

Applications and Tools<br />

Analog Devices, Inc.<br />

Analog Devices’ ARM7 series integrates high-precision<br />

analog with an ARM7TDMI core. The small size and<br />

integration of these devices makes them particularly<br />

useful in a<br />

wide range of<br />

applications.<br />

Experiencing the<br />

product training<br />

module regarding<br />

the ARM7 series will<br />

provide insight into<br />

the industrial and<br />

medical applications of which the device is often utilized,<br />

along with example MicroConverter reference design<br />

examples for the benefi t of any<br />

purchaser.<br />

USB-Based Emulator (ADZS-USB-ICE-ND)<br />

Analog Devices’ cost-effective Universal Serial Bus (USB)-<br />

based emulator provides an easy, portable, non-intrusive,<br />

target-based debugging solution for Analog Devices JTAG<br />

processors and DSPs. This powerful USB-based emulator<br />

performs a wide range of emulation functions, including<br />

single-step and full speed execution with pre-defi ned<br />

breakpoints, and viewing and/or altering of register and<br />

memory contents. With the ability to automatically detect<br />

and support multiple I/O voltages, the USB emulator enables<br />

users to communicate with all of the Analog Devices JTAG<br />

processors and DSPs using a<br />

full speed USB 1.1 on the host<br />

PC. Applications and data can<br />

easily and rapidly be tested<br />

and transferred between the<br />

emulators and the separately<br />

available VisualDSP++<br />

development and debugging<br />

environment (sold separately).<br />

www.digikey.ca/ptm<br />

www.devtoolsxpress.com<br />

ADuC7122: Precision Analog <strong>Microcontroller</strong>, 12-Bit Analog I/O, ARM7TDMI MCU<br />

The ADuC7122 is a fully integrated, 1 MSPS, 12-bit data acquisition<br />

system, incorporating high performance multichannel ADCs, 12 voltage<br />

output DACs, 16-bit/32-bit MCUs, and Flash/EE memory on a single<br />

chip. The ADC consists of up to 13 inputs. Four of these inputs can be<br />

confi gured as differential pairs with a Programmable Gain Amplifi er on<br />

their front end providing a gain between 1 and 5. The ADC can operate<br />

in single-ended or differential input modes. The ADC input voltage is<br />

0 V to VREF. A low drift band gap reference, temperature sensor, and<br />

supply voltage monitor complete the ADC peripheral set.<br />

• 13 external channel, 12-bit,<br />

1 MSPS ADC<br />

• 11 general-purpose inputs<br />

• 0 V to VREF analog input range<br />

• 12 × 12-bit voltage output DACs<br />

• ARM7TDMI core, 16-bit/32-<br />

bit RISC architecture<br />

• JTAG port supports code<br />

download and debug<br />

• 41.78 MHz PLL with<br />

programmable divider<br />

• 126 kB Flash/EE memory, 8 kB<br />

SRAM<br />

• UART, 2 × I 2 C ® and SPI serial I/O<br />

• Wake-up and watchdog timers<br />

(WDT)<br />

• Specifi ed for 3 V operation<br />

• Active mode: 11 mA at 5 MHz,<br />

40 mA at 41.78 MHz<br />

Analog Devices and Digi-Key present New Product Express – a fast, easy way to<br />

get ADI’s newest products. These products are in full production, having passed<br />

ADI’s quality and reliability testing, and are available from Digi-Key to order today!<br />

See New Product Express at www.digikey.com/newproductexpress<br />

www.digikey.ca/analogdevices-mcu<br />

14


Introducing a Second MCU<br />

to Embedded Designs<br />

by Nicholas Cravotta<br />

There are numerous reasons to add a second<br />

MCU to your design and numerous errors to<br />

avoid once you do. This article considers the<br />

arguments and options while pointing out the<br />

pitfalls along the way.<br />

With the wide variety of processors available today, there are a<br />

great many reasons why you may find it to be a more cost-effective<br />

choice to add new features to an application by introducing a<br />

second microcontroller (MCU) or microprocessor (MPU) to your<br />

design rather than trying to perform every task on a single, higher<br />

performance processor:<br />

• Cost: Migrating to a higher performance system MPU can have a<br />

higher cost differential than adding an 8- or 16-bit MCU to take<br />

on the added load.<br />

• Power: Rather than expend the power to have the main<br />

application processor continuously turn itself on to perform a<br />

relatively simple operation such as monitoring a sensor bank<br />

or checking if a key has been pressed, an 8-bit processor<br />

can be introduced to perform these tasks. In essence, the<br />

8-bit processor serves as a “power gate” by letting the main<br />

processor sleep and waking it only when an event occurs that<br />

requires its attention. This is especially effective with resistive<br />

and surface capacitive touchscreens.<br />

• Determinism: User interface (UI) functions involving compute<br />

intensive tasks such as animation or audio can stress the<br />

real-time deterministic behavior of a system. Rather than risk the<br />

reliability of critical tasks such as motor control, a second MCU<br />

can assume all “real-time” UI responsibilities.<br />

• Diversity: Many systems can benefit from a modular design. For<br />

example, a display module can be implemented with a different<br />

processor to provide additional graphics, or streaming video<br />

capabilities. By taking a modular approach, the main application<br />

code does not need to be changed to add new features to the<br />

system or to support different models.<br />

• Simplicity: A product line may offer a wide variety of options.<br />

For example, a product may have four screens, three keyboards,<br />

and three connectivity options. When a single processor is<br />

used, the design team has to maintain, test, and verify a<br />

separate code version for each possible variant (4x3x3=36<br />

distinct variants). When a secondary processor is used to<br />

implement a new function, maintenance is required only<br />

for each option (4+3+3=10). Note that with the first option,<br />

the entire system needs to be tested and verified with every<br />

variant, a complex and time-consuming process. When using<br />

the second option, the main application code only needs to be<br />

verified once. Each of the options can be verified separately<br />

and with significantly less complexity.<br />

• Conservation of I/O: An MCU can appear to be several devices<br />

over an interface by responding to several addresses. For<br />

example, the main application processor could issue a command<br />

to turn on a fan which is intercepted by an MCU serving as a<br />

virtual hub. This is an effective way to conserve I/O on the main<br />

application processor since only one communication peripheral<br />

is required to read and control multiple devices.<br />

• Certification: Changing the user interface or introducing a new<br />

interface like Wi-Fi to the main system requires the entire design<br />

to be recertified for some markets. Implementing these functions<br />

as an add-on module with a separate processor simplifies<br />

the recertification process, significantly accelerating both<br />

development and time-to-market.<br />

UART, I 2 C, and SPI<br />

There are many options available for interconnecting processors.<br />

The most basic interfaces used for this purpose are Universal<br />

Asynchronous Receiver-Transmitter (UART), Inter-Integrated Circuit<br />

(I 2 C), and Serial Peripheral Interface (SPI). Today, many processors<br />

offer hardware and software support for one or more of these<br />

interfaces. For example, STMicroelectronicss’ STM32 Cortex-M3 32-<br />

bit processors and 8-bit STM8L MCUs support all three. Alternatively,<br />

Cypress’ PSoC family of programmable system-on-chip processors<br />

have analog and digital blocks which can be configured to provide<br />

multiple instances of each of these interfaces, allowing the interface<br />

mix to be altered as required for different target markets. The<br />

question becomes how many interfaces you’re going to need.<br />

A UART operates up to 250 kbps, compared to 100 to 400 kbps for<br />

I 2 C. SPI, which supplies its own clock, can operate at speeds over<br />

1 Mbps. A UART link can typically be implemented in software using<br />

an interrupt-based driver, so long as the driver doesn’t place too much<br />

load or latency on the processor based on the application’s needs. An<br />

I 2 C master can often be implemented in software, but a slave needs to<br />

www.digikey.ca/microcontroller<br />

15


e implemented in hardware because of the data rates involved. SPI<br />

also needs to be hardware-based. Multi-master systems will need to<br />

be hardware-based as well.<br />

Beyond data rate, each interface offers specifi c features that may<br />

make it more appropriate for a specifi c application. UART is extremely<br />

simple to implement and is full-duplex. I 2 C is popular because it<br />

requires only two wires, can have a simple master, and offers a<br />

variety of advanced options including support for addressing, multiple<br />

masters, broadcasting, and clock stretching. Clock stretching, for<br />

example, allows an I 2 C slave to hold the clock and halt the fl ow of<br />

data while it processes the data it has received, thus preventing<br />

potential overrun issues. In contrast, a SPI slave is at the mercy of<br />

the SPI master.<br />

With all of the various options available for I 2 C and SPI, many silicon<br />

vendors supply example code which you’ll need to use as a model<br />

for creating your own code. Fortunately drivers for these interfaces<br />

can be fairly simple – an I 2 C driver can be 15 lines of code, allowing<br />

you to implement an interface in a short period of time. However, it is<br />

important that you determine which features you need to support, that<br />

you’ve implemented them correctly, and that the master and slave<br />

implement the same features.<br />

For example, there are a number of parameters you’ll need to decide<br />

upon when creating an I 2 C driver, such as 7- or 11-bit addressing,<br />

single or multi-master (with collision detection and recovery), data<br />

rate, whether to use ACK/NAK protocols, support for address holding,<br />

and a slew of other options. As a result, any two particular I 2 C<br />

interfaces can be very different. For example, one common problem<br />

developers run into is mistaking the System Management Bus<br />

(SMBus) used in laptops as a simple I 2 C bus. Even though the SMBus<br />

runs over an I 2 C interface, it usually uses fi xed voltages for high and<br />

low values whereas a generic I 2 C interface uses threshold values<br />

which are typically based on a percentage of the MCU power supply,<br />

thus representing a potential discrepancy between the two which can<br />

create diffi cult-to-debug intermittent errors.<br />

Note too, that UART, I 2 C, and SPI are just physical interfaces. You’ll still<br />

need to supply a logical protocol that operates on top of the physical<br />

layer. If the interface is between two MCUs under your design, this<br />

protocol can be whatever you want it to be. If the MCU is talking to<br />

a device like a serial EEPROM, then the protocol is already defi ned<br />

for you. As a consequence, a driver for a master is likely to be more<br />

complex than a slave given the number of different devices and their<br />

protocols it may communicate with. In addition, if your master doesn’t<br />

support all of the protocols features a slave does (or, conversely, tries<br />

to use a feature a slave does not support), compatibility problems will<br />

eventually surface.<br />

The simplicity of each of these interfaces is both its advantage and<br />

curse. You can implement intricate protocols, which makes the<br />

interface more effi cient and powerful, but this can also make it more<br />

diffi cult to debug. The simplicity gives you all the rope you need to<br />

hang the system up if you aren’t careful.<br />

For example, consider an application where the interface is<br />

controlling an analog multiplexer which needs to smoothly transition<br />

between two audio streams. Depending upon how the transition is<br />

implemented, there can be undesirable – and audible – side effects;<br />

i.e., switching from a soft to loud stream can result in a loud “Pop!”<br />

Additionally, command latency may affect the transition. Ideally,<br />

you’ll want to run the audio down, switch streams, and then run<br />

the audio back up. However, this may not always be convenient for<br />

your application. The same diffi culties apply if you are working with<br />

multiple power supplies at the same time.<br />

To facilitate initial driver design and verifi cation, many vendors<br />

offer powerful development tools for implementing and verifying<br />

interface functionality. For example, Microchip offers the PICkit Serial<br />

Analyzer which connects to your system and to a PC which you use<br />

to confi gure the link as a master or slave with any of the standard<br />

interface options for UART, I 2 C, and SPI. A classic problem in interface<br />

design is the need for a pre-existing master to design a slave or<br />

a pre-existing slave to design a master. The PICkit eliminates this<br />

problem by providing a reliable other half of the link to design against<br />

with visibility into what’s being sent over both sides of the link. The<br />

PICkit also has the capable of emulating a variety of I 2 C peripherals<br />

like ADCs and fan controllers.<br />

Many MCU vendors also offer a variety of full-featured development<br />

kits and libraries to facilitate the introduction of subsystems such<br />

as an LCD display, touchscreen, or other peripheral to a system.<br />

For example, TI offers the RDKIDML-35 Intelligent Display module<br />

reference design kit which makes it relatively easy to add a 3.5”<br />

QVGA touchscreen to a system connected over either an I 2 C or SPI<br />

link. The kit also includes a software library with various GUI functions<br />

to speed user interface design.<br />

Figure 1: PICKit Serial Analyzer.<br />

Avoiding common pitfalls<br />

In the end, the best way to learn to implement a UART, I 2 C, or SPI<br />

link is to do it yourself. The following list of tips and tricks has been<br />

suggested by experts from a variety of MCU manufacturers to help<br />

you avoid some of the more common mistakes, misconceptions,<br />

and missteps developers often take when implementing their fi rst<br />

processor-to-processor interface.<br />

16


Introduce complexity in stages: Do not try to implement the entire<br />

system from the start. Begin with the basic driver and verify its<br />

operation. Then add the protocol layer and verify again. Introduce<br />

the application layer. Finally, operate the entire system with all of its<br />

various concurrent tasks and interdependencies.<br />

Design your system to abstract functionality: For example,<br />

using a generic UI interface allows the main system to connect to<br />

mechanical buttons, a keypad, or a touchscreen without having to<br />

know which is actually connected. This approach also allows you to<br />

fundamentally modify how a function is performed without requiring<br />

any code changes to the main system. Consider a vending machine<br />

with a separate processor handling coin and bill collection. If a<br />

security problem arises (i.e., customers have figured out a way to<br />

cheat the machine), only the hardware and software used to monitor<br />

collection need to be redesigned to prevent this; the rest of the<br />

system remains unchanged.<br />

Figure 2: RDK_IDM L35.<br />

Recognize that peripherals are different than processors:<br />

Connecting to a peripheral is different than connecting to another<br />

processor. When you control the software on both sides of the<br />

interface, you define the interface specifics and protocol on both<br />

sides and can therefore guarantee compatibility. When you only<br />

design one side of the interface, you need to design your interface<br />

to match the requirements of the peripheral to which you are<br />

connecting. This can give rise to many potential problems. The<br />

most common is the datasheet for the peripheral inaccurately<br />

describing how the interface has been implemented. To avoid this<br />

problem, verify how the interface has been implemented. Also be<br />

aware that various interface options such as 11-bit addressing,<br />

clock stretching, or multi-master support may not be supported<br />

by a peripheral and that if you try to implement a feature that the<br />

peripheral did not implement, the results will be unpredictable.<br />

Specify a sufficient data rate: Confirm that the data rate of the<br />

interface will meet both your current and future data needs. For<br />

example, a small display requires a lower data rate than a larger<br />

display or equivalent touchscreen. If you plan to support larger<br />

displays in next-generation designs, keep your interface options open.<br />

Account for overruns: Getting an I 2 C or SPI link up and going is<br />

fairly straightforward. Where you are likely to encounter difficulties<br />

is at the corner cases. For example, the interface may operate<br />

properly up to a certain frequency, at which point it begins to fail.<br />

The problem could either be from too much noise in the system<br />

or a data overrun. A data overrun may be a local problem; a series<br />

of a particular type of packet may require more processing time,<br />

resulting in the processor not emptying the buffer fast enough. More<br />

often, overruns are caused by system-level issues. For example,<br />

the DMA or FIFO used by the interface may be a shared resource.<br />

Depending upon what else is being processed by the system (i.e.,<br />

the real-time operating system is managing several real-time tasks<br />

simultaneously), latencies may be greater than estimated, causing<br />

an overrun.<br />

Verify the driver first: When a problem arises, it can be difficult to<br />

determine the cause of the error. This is especially true in systems<br />

managing multiple interfaces or real-time tasks where errors<br />

can arise because of what else is happening in the system. Get<br />

the systems talking reliably first by verifying your drivers before<br />

introducing application-level functionality. This allows you to more<br />

confidently eliminate the driver as the source of the problem during<br />

later debugging.<br />

Debug using code instrumentation: Debugging both sides of<br />

an interface can be tricky because you are working with multiple<br />

processors. While there are tools for debugging multiprocessor<br />

systems, they often allow you to halt only one side of the link, making<br />

it difficult to utilize traditional debugging techniques. If you are using<br />

the same type of processor on both sides of the link, you have the<br />

option of having the one processor send and then receive its own<br />

signal; this allows you to watch both sides of the link and halt them<br />

simultaneously. If you are debugging over JTAG, you may be able to<br />

connect both processors to the same JTAG chain.<br />

Once you mix architectures, however, you may find yourself forced<br />

to debug one side of the link at a time. To simplify debugging,<br />

limit the complexity of the other side of the link by creating a<br />

simple stub driver that allows you to test basic functionality in<br />

stages. As you begin to work with live systems on both sides of<br />

the link, you can use the debugger on one side of the link and use<br />

code instrumentation techniques on the other side of the link to<br />

facilitate debugging. The instrumented side of the link can use the<br />

link itself to send status information such as variable values, data<br />

received, and other important information back to the processor<br />

being debugged.<br />

Exploit your debugger: Some engineers try to solve programming<br />

issues without a debugger. When they encounter an error, they try<br />

something different in the code. Many interface issues, however,<br />

are caused at the system level and rewriting interface driver code<br />

is not the solution. Observing these system-level interactions may<br />

require a debugger.<br />

Check your connections: Triple-check your connections before<br />

debugging a problem. For example, an easy error to make is to hook<br />

up the control signals of the interface but fail to have a common<br />

ground. Do this and you may find yourself spending hours trying to<br />

resolve a non-existent problem.<br />

www.digikey.ca/microcontroller<br />

17


Document your code: Take the time to write clean code with<br />

complete comments. A simple I 2 C driver might only run 15 lines<br />

and not seem to require documentation. However, if you are new<br />

to I 2 C, you may have missed a critical parameter that you come to<br />

understand more about at a later time. Complete documentation<br />

gives you a reliable path for tracking your changes in thinking and not<br />

getting lost as the complexity of the application increases.<br />

Question the spec sheet: Because of its greater fl exibility,<br />

developers typically encounter more issues with I 2 C than with<br />

SPI. For example, the slave can adversely affect the master by<br />

holding the clock down, using a different addressing mode, or<br />

implementing start/stop sequences differently. Be wary even if you<br />

are connecting to a peripheral like a sensor with a detailed data<br />

sheet. The peripheral may not follow the spec, so don’t immediately<br />

assume your driver or the MCU is at fault if you can’t get an interface<br />

working. It is times like these that you may need a logic analyzer to<br />

locate the true source of the problem.<br />

Have access to a logic analyzer: This tool is especially useful when<br />

you have to connect to another device with an existing interface<br />

and protocol. It can also accelerate development when connecting<br />

to peripherals with a parallel interface like a display. Be sure to<br />

check if your logic analyzer supports the appropriate decode for<br />

the interface you are using. Automatic decoding can substantially<br />

simplify debugging by allowing you to observe the interface as a<br />

logical signal rather than having to convert the physical signal to a<br />

logical signal yourself.<br />

Design for coexistence: In a multi-master system, sometimes you<br />

will need to make sure to send data to multiple destinations without<br />

risking giving up the bus to another master. To achieve this, you can<br />

use a restart condition between each transmission to keep control<br />

of the bus. Similarly, you can use a restart to change the direction<br />

of data to receive data from a slave (i.e., EEPROM) without letting<br />

go of the bus. A master that locks the bus in this way, however, can<br />

create latency issues for other masters performing tasks that are<br />

also time-critical. Use such techniques sparingly and thoroughly test<br />

the interplay between masters to ensure that they operate well with<br />

each other.<br />

Design slave/master-capable drivers: Consider giving your slaves<br />

the ability to become a master. This can be useful in the case of<br />

system failure, allowing a slave to take over the bus and initiate<br />

recovery mechanisms with signifi cantly less latency than if the slave<br />

has to wait until it is addressed before it can signal an alert.<br />

Separate data processing from data transmission: Often, the<br />

data collected (i.e., a voltage from a temperature sensor) is very<br />

different from the data that needs to be transferred (i.e., whether a<br />

temperature threshold has been crossed). Consider an interface to a<br />

touchscreen module where the main system, acting as the master,<br />

asks for the current fi nger position data. The module collects the<br />

raw data and stores it until position data is requested by the master.<br />

At this time, the module retrieves the raw data, processes it, and<br />

then transmits it.<br />

This particular architecture can innocently create an overrun<br />

condition. Consider that to maintain responsiveness, the main system<br />

may ask for information at a higher frequency than at which the raw<br />

data actually changes. This means that with each request, the module<br />

has to recompute the position data using data-intensive algorithms,<br />

even if the data has not changed. Because the raw data is being<br />

computed multiple times, the result is tremendous overhead that can<br />

affect the responsiveness of the module.<br />

There are several ways to eliminate such overhead. For example,<br />

a check could be made before the position data is computed as to<br />

whether the raw data has changed suffi ciently or not. If the raw data<br />

has not changed, the previous calculation is used. Another approach<br />

would be to have the touchscreen module serve as the master over<br />

the link and send an update whenever the position has changed.<br />

Keep the interface simple: If you only have one master and one<br />

slave, there is no need to implement address collision. Of course, take<br />

into consideration future expansion and whether a deployed device<br />

may need to support such a feature to be compatible with future<br />

generations of devices.<br />

With today’s integrated MCUs and MPUs, coupled with powerful<br />

development tools, designing your fi rst processor-to-processor<br />

interface can be a simple process that allows you to quickly introduce<br />

a second processor to your existing design. By taking care in your<br />

design, you can avoid many common pitfalls to create a reliable<br />

and effi cient interface that will meet the performance needs of your<br />

application today and into the future.<br />

ATmega128RFA1<br />

Wireless MCU<br />

Atmel<br />

The ATmega128RFA1 wireless MCU is a single-chip<br />

microcontroller that is known as the world’s fi rst<br />

wireless AVR. This device consists of a unique Atmel<br />

microcontroller and an RF transceiver and offers the<br />

highest system<br />

integration and best<br />

cost-effi ciency.<br />

Digi-Key’s product<br />

training module<br />

for this product<br />

features information<br />

regarding the<br />

integration of<br />

the AVR MCU with the RF module, reviews the power<br />

specifi cations offered with this series, and provides<br />

in-depth application examples.<br />

www.digikey.ca/ptm<br />

18


Eliminating the Parallel/Serial<br />

Tradeoff in Embedded Systems<br />

with SPIFI-Equipped Cortex-M3<br />

by Rob Cosaro and Gene Carter, NXP Semiconductors<br />

Choosing parallel versus serial flash has<br />

traditionally meant gaining speed at the cost of<br />

complexity. This no longer needs to be the case.<br />

The SPI Flash Interface (SPIFI), a patent-pending feature initially available<br />

on NXP’s latest ARM Cortex-M3 microcontrollers, lets designers of 32-bit<br />

embedded systems use a small, inexpensive serial flash in place of a<br />

larger, more expensive parallel flash. With SPIFI (“spiffy”), the external<br />

serial flash appears in the microcontroller’s memory map and can be<br />

read like other on-chip memory. This essentially eliminates the traditional<br />

tradeoff associated with choosing the type of external flash to be used in<br />

an embedded system, and gives designers a new way to minimize size<br />

and cost while delivering the required system performance.<br />

NXP has developed a peripheral function, initially available on its new<br />

ARM-based LPC1800 Cortex-M3 microcontrollers, that lets designers of<br />

embedded systems use external serial flash memory in place of larger,<br />

more expensive parallel flash. The patent-pending peripheral, called<br />

the SPI Flash Interface (SPIFI), lets external serial flash memory appear<br />

in the microcontroller’s memory map, so it can be read like an on-chip<br />

memory. This gives designers a new way to meet performance demands<br />

while creating a system that is easier to configure, uses smaller<br />

packages, requires less board space, and is less expensive to build.<br />

The need for external flash<br />

Embedded applications that use a 32-bit microcontroller (MCU) are<br />

increasingly tasked with offering a range of sophisticated features<br />

for managing multimedia, photos, and other data-intensive content.<br />

This is particularly true of systems that present a human interface,<br />

since today’s users have come to expect a graphical display that lets<br />

them interact with window boxes, photos, animations, sound files,<br />

and more. As products become increasingly international, they have to<br />

operate in different languages and may need to support several sets<br />

of alphabets and non-Roman characters. All these requirements place<br />

extra demands on the system’s memory resources.<br />

Most 32-bit microcontrollers are equipped with on-chip flash memory<br />

that can be used to support data-intensive features, but it’s often not<br />

enough to support the entire application. The on-chip flash is typically<br />

limited to 1 Megabyte or less. That may be enough to house the bulk<br />

of the critical application code, but it may fall short when it comes<br />

to storing all the other things the application needs, such as look-up<br />

tables, images, photos, sound files, multiple languages, and so on. For<br />

these items, designers often turn to external flash memory.<br />

External flash memory is significantly cheaper than on-chip flash<br />

and is readily available in sizes in excess of 8 Megabytes. Flash<br />

memory can also add an extra level of flexibility to the system,<br />

since it can be used to patch or upgrade software once the system<br />

is in the field.<br />

The parallel/serial tradeoff<br />

When choosing what kind of external flash to use, parallel or serial,<br />

designers have traditionally had to balance several tradeoffs. Parallel<br />

flash is often faster than serial flash, but requires more pins, more<br />

PCB traces, and more board space.<br />

Figure 1 shows data transfer rates for typical parallel and serial flash<br />

devices. For the parallel flash, the graph assumes a fixed access<br />

time of roughly 90 ns without buffering. With these conditions the<br />

maximum transfer rate for a 16-bit-wide parallel flash is 22 Mbytes/<br />

sec. For the serial flash the maximum clock frequency is 80 MHz<br />

giving a per-bit transfer rate of 80 Mbits/sec. For a quad device<br />

this means a maximum transfer rate of 40 Mbytes/second. This<br />

calculation ignores any control bits but quad SPI devices support<br />

bursting which is used by the SPIFI interface This allows the SPIFI<br />

interface to approach these transfer rates.<br />

Figure 1: Typical transfer rates of serial and parallel flash memories.<br />

Table 1: Parallel verus Serial Flash Performance.<br />

Interface Mode Access Time (nS) Effective Throughput (MB/S)<br />

Parallel<br />

8 Bits 90 11<br />

16 Bits 90 22<br />

Single 12.5* 10<br />

Serial Dual 12.5* 20<br />

Quad 12.5* 40<br />

*Effective access time.<br />

www.digikey.ca/microcontroller<br />

19


As shown in Figure 1, a typical 16-bit parallel fl ash memory delivers a<br />

data transfer rate of 20 Megabytes per second. In systems that use<br />

a 32-bit microcontroller with a 32-bit bus for the external memory<br />

(like those from NXP), the designer can opt to use two 16-bit parallel<br />

devices in combination for a rate of 40 Megabytes per second.<br />

However, the added speed comes at a cost. The confi guration uses<br />

two separate parallel fl ash memories, each housed in a package<br />

with dozens of pins, and that may be more, in terms of package<br />

size, pin count, and PCB space, than the designer can afford.<br />

Serial fl ash, which typically uses the simple four-pin Serial<br />

Peripheral Interface (SPI), can be a good alternative to parallel<br />

fl ash when space, power, and cost are concerns, but it’s much<br />

slower. Figure 1 shows that a typical SPI fl ash operating at 50<br />

MHz transfers data at roughly 5 Megabytes per second (eight<br />

times slower than a confi guration that uses two 16-bit parallel<br />

devices). Another consideration is that the SPI interface on most<br />

microcontrollers is connected to the MCU’s peripheral matrix, where<br />

data has to be received by driver code and put into on-board RAM<br />

before the processor can access it. This can slow things down,<br />

since each read from serial fl ash has to go through an SPI software<br />

layer. Depending on the application, using the standard SPI interface<br />

for external memory may not be fast enough.<br />

The new Quad SPI fl ash format, which uses a modifi ed, six-pin SPI<br />

confi guration, is much faster than traditional SPI formats. As shown<br />

in Figure 1, Quad SPI delivers a transfer rate of 40 Megabytes per<br />

second, which is the same as using two 16-bit parallel devices.<br />

Using Quad SPI is often much less expensive than the parallel<br />

approach, since it uses far fewer pins and a much smaller package.<br />

It would seem that Quad SPI fl ash would be a good replacement for<br />

parallel fl ash in embedded systems, but the reality is that today’s<br />

32-bit microcontrollers aren’t designed to support Quad SPI fl ash<br />

at its maximum speeds. This is because the Quad SPI interface, like<br />

the traditional SPI interface, is connected to the microcontroller’s<br />

peripheral matrix.<br />

Eliminating the tradeoff<br />

NXP has developed a new peripheral function, called the SPI<br />

Flash Interface (SPIFI) that essentially eliminates the parallel/<br />

serial tradeoff. The patent-pending SPIFI (“spiffy”) peripheral lets<br />

low-cost SPI and new Quad SPI fl ash memories appear in the<br />

memory map of an ARM Cortex-M3 microcontroller, so the MCU<br />

can use external SPI fl ash with only a minimal performance penalty<br />

compared to external parallel fl ash memories. The complete<br />

memory space of the external SPI fl ash appears in the MCU’s<br />

memory map, so the microcontroller can access the external<br />

memory directly, without a software API or library.<br />

When used with a Quad SPI fl ash, for example, the SPIFI peripheral<br />

supports a data transfer rate of up to 40 Megabytes per second.<br />

The designer can choose a less expensive SPI fl ash device, with<br />

its compact footprint and simple confi guration, but doesn’t have<br />

to sacrifi ce performance. The designer may also be able to choose<br />

a smaller, less costly microcontroller, because the system won’t<br />

need a bulky interface for external parallel memory. The SPIFI<br />

peripheral enables an embedded system that makes better use<br />

of memory resources yet remains compact and effi cient while<br />

lowering overall cost.<br />

The SPIFI peripheral is a dedicated function that will initially<br />

be available on the NXP LPC1800 series of ARM Cortex-M3<br />

microcontrollers. It will also be available on upcoming product lines,<br />

including the low-cost Cortex-M0 series and the Cortex M4 line of<br />

digital serial controllers (DSCs).<br />

SPIFI supports most serial fl ash devices on the market today<br />

(including those with quad read/write capability) and is designed<br />

for easy confi guration and programming. It uses four or six pins<br />

(depending on the type of serial fl ash used), works with a small<br />

register set, is optimized for effi cient memory transactions, and<br />

uses software commands that reduce CPU overhead and streamline<br />

memory interactions.<br />

How SPIFI works<br />

Figure 2 shows a block diagram of the SPIFI peripheral. The SPIFI<br />

function is connected to the microcontroller’s Application Highspeed<br />

Bus (AHB) matrix, which is used for the processor core and<br />

the on-chip memories. The SPIFI peripheral presents the contents<br />

of the external SPI fl ash in the microcontroller’s memory map. Once<br />

the boot code in the on-chip ROM initializes the SPIFI interface, the<br />

external SPI memory looks just like an on-chip memory to the core<br />

processing unit.<br />

Figure 2: Block diagram of the SPIFI peripheral.<br />

Initialization sequence<br />

All of the drivers required for the SPIFI interface are available in<br />

ROM. For reading, only one call to a routine is made to initialize the<br />

SPIFI peripheral. After the initialization sequence, the entire SPI fl ash<br />

content is accessible as normal memory using byte, half word, and<br />

word accesses by the processor and/or the DMA channels. Erasure<br />

and programming are handled by a simple API call, which accesses<br />

commands in ROM, so using the external SPI memory is as easy as<br />

using on-chip fl ash memory.<br />

Booting from SPIFI<br />

For systems that need the microcontroller to boot from external<br />

serial fl ash, the NXP LPC1800 microcontroller has been equipped<br />

with a mechanism that includes SPIFI as a boot source. There<br />

are two ways to select the boot source. The fi rst uses the<br />

microcontroller pins to determine which interface to boot from, and<br />

the second relies on the user to program a non-volatile location to<br />

choose the interface. Using the non-volatile location saves the pins<br />

from having dual-use functions.<br />

20


Physical interface<br />

Figure 3 shows the physical interface of the SPIFI peripheral. It uses the<br />

standard four pins for traditional SPI devices; when configured with Quad<br />

SPI memory it uses an additional two pins to support the quad capability.<br />

Figure 3: Physical interface of the SPIFI peripheral.<br />

Different serial flash vendors and devices accept or require<br />

different commands and command formats. The SPIFI peripheral provides<br />

sufficient flexibility to be compatible with most common SPI flash and<br />

includes extensions to help insure compatibility with future devices.<br />

Reduced register set<br />

A compact register set gives the SPIFI peripheral a considerable amount<br />

of intelligence while keeping it simple to use. It takes just eight registers<br />

to control the SPIFI function, interface with the external SPI memory,<br />

store and retrieve data, and monitor operation. Since the built-in ROM<br />

API governs setup, programming, and erasure, handling the external SPI<br />

memory in an application is a matter of a few calls. As a result, the SPIFI<br />

peripheral is simple to configure and easy to support in the application.<br />

Software commands<br />

The external memory responds to commands sent by the<br />

microcontroller software and to commands automatically sent by the<br />

SPIFI peripheral when its software reads the serial fl ash region of<br />

the memory map. Commands are divided into fi elds called opcode,<br />

address, intermediate, and data. The address, intermediate, and<br />

data fi elds are optional depending on the opcode. Some memory<br />

devices include a mode in which the opcode can be implied in Read<br />

commands for higher performance. Data fi elds are further divided into<br />

input and output data fi elds depending on the opcode. All commands<br />

to the external SPI memory can be handled by calls to the ROM API.<br />

The SPIFI ROM API driver lets the contents of the external SPI memory<br />

be accessed using simple load commands, so the application code<br />

remains compact and easy to write.<br />

CPU-independent operation<br />

The SPIFI software can read data from the external memory and write it<br />

to RAM or a peripheral without involving the CPU. With microcontrollers<br />

that have an integrated LCD controller, for example, this feature can be<br />

used to enhance performance and save power. Images can be stored in<br />

the external memory and fetched by the LCD controller. Since the LCD<br />

controller reads most of its data from sequential addresses, the SPIFI<br />

peripheral can pre-fetch the addresses so they’re ready when needed,<br />

with essentially no wait states. The entire operation can happen without<br />

getting the CPU involved, and there’s no need to load the images into<br />

on-chip RAM before the LCD controller fetches them. That means the<br />

system can use a microcontroller with less on-chip RAM, or can free<br />

up its existing RAM for other tasks. Also, since the images are fetched<br />

directly by the LCD controller, the LCD display can refresh graphics<br />

faster, so simple operations like opening and closing windows appear<br />

smoother. Also, to save power, the system can use a slower clock speed<br />

without having a noticeable impact on the display’s performance.<br />

Direct execution<br />

From a software point of view, the microcontroller can execute code<br />

directly from the external SPI memory. Direct execution can be helpful<br />

when using in-fi eld upgrades or when replacing functions originally<br />

shipped in on-chip fl ash. Validated upgrade code can be placed in the<br />

external fl ash. If, for example, the system’s function addresses are in<br />

a table stored in on-chip fl ash, the table can be reprogrammed with<br />

the address of the routine now housed in external fl ash. Alternatively,<br />

if the page containing the start of the original routine is stored in<br />

on-chip fl ash, the page can be updated with a branch long jump to<br />

the new routine in external fl ash. In either case, the new code doesn’t<br />

need to be loaded into the on-chip RAM to execute, because the SPIFI<br />

peripheral allows direct execution from the external memory.<br />

Executing code from an external memory is never as fast as using<br />

on-chip memory. The SPIFI peripheral isn’t intended for use with<br />

real-time functions that require peak performance but, for less critical<br />

code sequences, SPIFI can be a very attractive option.<br />

Write-while-execute functions<br />

The SPIFI supports write-while-execute functionality, which means it<br />

can program or erase the external memory simply and quickly, even<br />

when the processor is executing code from on-chip fl ash. Since the<br />

SPIFI peripheral can run on its own, without interaction from the CPU,<br />

the system can perform its functions without interruption while the<br />

serial fl ash is being reprogrammed.<br />

This feature can be used to perform software upgrades in the fi eld,<br />

because the system can write to the external memory without<br />

interrupting critical application code. In a smart meter, for example,<br />

the metering function needs to operate continuously, even during a<br />

software upgrade. With SPIFI, the utility company can confi gure the<br />

system to write any new code to external fl ash, without interrupting<br />

the active metering function, and can then integrate the new code<br />

into the system. Similarly, in a system that has a USB port, new code<br />

can be placed on a portable USB drive and transferred to the external<br />

fl ash without interrupting critical operations.<br />

Conclusions<br />

NXP’s new SPI Flash Interface (SPIFI), a patent-pending feature initially<br />

available on its new ARM-based LPC1800 Cortex-M3 microcontrollers,<br />

lets external serial fl ash memory appear in the microcontroller’s<br />

memory map, so it can be read like on-chip memory. This gives<br />

designers access to a large amount of external fl ash memory while<br />

reducing system costs and minimizing the design footprint.<br />

The SPIFI peripheral creates a way for designers to use a small,<br />

inexpensive serial flash where they might previously have needed to use<br />

a larger, more expensive parallel flash to meet the system’s performance<br />

requirements. Designers can take advantage of the many benefits of<br />

serial flash — low-cost, small size, simple configuration — without<br />

making large sacrifices in performance. SPIFI also lets designers opt for<br />

a microcontroller without a parallel interface, for a smaller, less expensive<br />

design that still delivers the required performance.<br />

The NXP roadmap for SPIFI includes migration to other Cortex-M<br />

families, including the low-cost Cortex-M0 series and the upcoming<br />

Cortex-M4 series of Digital Signal Controllers.<br />

www.digikey.ca/microcontroller<br />

21


uIP TCP/IP Protocol<br />

Stack Demonstration<br />

contributed by Renesas Corporation<br />

The popular open source uIP TCP/IP stack<br />

is widely used in embedded designs. This<br />

demo provides both hands-on experience and<br />

insights into its use.<br />

This article demonstrates the features and capabilities of the RX62N<br />

Renesas Ethernet connectivity target devices with the open source<br />

uIP TCP/IP protocol stack. It assumes some experience with Ethernet,<br />

TCP/IP, and HTML. For more introductory material on these subjects<br />

please see the references at the end of this article.<br />

The uIP TCP/IP stack demonstration project provides an example<br />

of Ethernet connectivity and a sample web server application that<br />

controls LEDs on the Renesas Starter Kit (RSK) boards.<br />

Overview<br />

The procedure below provides step by step instructions for how to<br />

setup the demonstration project and run it.<br />

Setup<br />

Set up a demonstration environment as shown in Figure 1. In this<br />

setup, a router is used as a DHCP server and a PC as a web client.<br />

Several RSK boards can be connected to the multiport router.<br />

Use straight RJ-45 Ethernet cables to make the connections.<br />

Depending on the RSK board used there may be other settings to<br />

be confi gured before running the demonstration project. These may<br />

include instructions for connecting a debugger to the RSK board.<br />

Please refer to the Quick Start Guide (QSG) of the RSK board for<br />

more information.<br />

Figure 2: Test setup.<br />

The demonstration project by default is confi gured to run in little endian<br />

mode. Please make sure RSK board is confi gured for the same endian<br />

mode. Refer to your QSG how to change endian mode of operation.<br />

For a simpler setup, an RSK board can be directly connected to a PC.<br />

In this setup, the router is not used and the demonstration project<br />

is designed to fall back to a static IP address if a DHCP server is not<br />

found in about ten seconds. In this case, the RSK board assumes the<br />

default IP address of 192.168.1.10.<br />

Figure 2 shows a more detailed test setup environment as an<br />

alternative. In this setup all devices are on the same collision domain<br />

and all network activity can be monitored and analyzed on the PC.<br />

If this setup is used, make sure the center connectivity device is a<br />

true hub rather than a switch. The router can be disconnected and<br />

connected back to the network independent of the connections<br />

between the PC and the RSK boards. This allows monitoring of RSK<br />

board behavior with or without a DHCP server on the network.<br />

Figure 1: Demonstration setup.<br />

Figure 3: Router network confi guration.<br />

22


Configure the IP address of the router to 192.168.1.1. This is<br />

usually the default IP address for most home or office routers.<br />

Configure the DHCP start IP address to 192.168.1.100 with two<br />

maximum DHCP users. A snapshot of the router configuration is<br />

shown in Figure 3.<br />

Configure the Ethernet port of the PC with a static IP address of<br />

192.168.1.2. Internet Protocol (TCP/IP) properties of the PC are<br />

shown in Figure 4. Make sure that this Ethernet port is not used to<br />

access a corporate network or a workgroup. If there is not a spare<br />

Ethernet port available, it is recommended to use an USB to an<br />

Ethernet adaptor. Please follow the adaptor manufacturer manual<br />

for installation instructions.<br />

Figure 5: Directory structure of uIP demonstration project.<br />

What to do with the demo<br />

The demonstration project displays “uIP Demo” on the RSK<br />

board LCD on power up. The IP address used is displayed on the<br />

LCD. The RSK board either receives its IP address from a DHCP<br />

server or uses its default setting of 192.168.1.10. For the test<br />

setup in this article, the DHCP server can assign IP addresses of<br />

192.168.1.100 and 192.168.1.101. Make sure the Ethernet cables<br />

are connected and devices are powered up if no IP address is<br />

displayed after ten seconds. Some of the possible LCD settings are<br />

shown in Figure 6.<br />

Figure 6: LCD settings.<br />

Figure 4: PC network configuration.<br />

Sample project directory structure<br />

Figure 5 shows the demonstration project directory structure. The \src<br />

folder contains the source code and has four subfolders: bsp, driver<br />

uip, and user-app. The \src\bsp and \src\driver folders have Renesas<br />

board specific source code and the Ethernet drivers for the RSK<br />

board. The uIP stack is in the \src\uip folder.<br />

The open source uIP TCP\IP stack comes with its own<br />

documentation. It is in the \src\uip\doc folder. The main.c file is<br />

in \src\uip\uip and the example web pages are in src\uip\apps\<br />

webserver\httpd-fs folders.<br />

The demonstration project includes a simple user application that<br />

controls the LEDs on the RSK board. This application is in the \src\<br />

user-application folder.<br />

The router’s status page can also be used to find which IP address<br />

is assigned to the RSK board as shown in Figure 7. Another way<br />

is simply to ping IP addresses and use the IP address with the<br />

reply. Ping messages can be generated by the following DOS<br />

Shell commands:<br />

C:\>ping 192.168.1.10<br />

C:\>ping 192.168.1.100<br />

C:\>ping 192.168.1.101<br />

Figure 7: DHCP client information.<br />

www.digikey.ca/microcontroller<br />

23


Launch a web browser and use the IP address of the RSK board<br />

in the URL fi eld. After a successful connection, the user will see<br />

the welcome page shown in Figure 8. This is also the front page.<br />

Note that the Renesas logo is linked to http://am.renesas.com/. By<br />

activating this link the user can easily access the Renesas Electronics<br />

America internet site. The other external link on this page is http://<br />

www.sics.se/~adam/uip. It is the main page for the uIP TCP/IP<br />

protocol stack.<br />

Figure 10: LED control web application page.<br />

Figure 8: uIP welcome page.<br />

All other pages can be accessed by links provided in the top banner.<br />

The fi le statistics page shows the number of times a specifi c page<br />

is accessed. The network statistics page displays the number of IP,<br />

ICMP, and TCP packet reception and transmission information. The<br />

network connections page shows the current status of established<br />

TCP connections within the uIP stack. These pages are dynamic and<br />

recreated every time they are accessed.<br />

Two custom pages are created and included within the demonstration<br />

project. First is the RSK board specifi c page. An example of this page<br />

is shown in Figure 9. In this case it is an RX62N custom page. The<br />

demonstration project is personalized for different target devices and<br />

target specifi c images are shown on this page. This is to show that<br />

creating custom web pages can be easily achieved and integrated<br />

with the uIP TCP/IP stack. The next section describes step by step<br />

instructions for creating a new web page.<br />

Figure 9: RSK custom page.<br />

The second custom page is the simple user application that controls<br />

the LEDs on the RSK board. One of the LEDs on the RSK board is<br />

used to indicate system timer activity. The other three are used by<br />

the LED control web page as shown in Figure 10. From this web<br />

page, the user can turn the LEDs on and off on the RSK board. The<br />

reset button selects the off setting for all LEDs. Note that the LED<br />

names in Figure 10 are generic and labeled as A, B, and C to allow<br />

portability between different RSK boards. They are usually grouped<br />

together on the target board.<br />

Steps to create a new web page<br />

A new web page can be easily created and added to the<br />

demonstration project by following the following steps. With a little<br />

HTML language knowledge, the user can create custom web page<br />

applications. All the tools and information needed are provided with<br />

the demonstration project and in this article.<br />

1. Write a new web page application. See the led.shtml example in<br />

src\uip\apps\webserver\httpd-fs.<br />

2. Copy it to src\uip\apps\webserver\httpd-fs directory.<br />

3. Run makefsdata.exe from src\uip\apps\webserver directory to<br />

generate the new fttpd-fsdat.c fi le.<br />

4. Rebuild the project.<br />

The makefsdata.exe is a Renesas add-on program created from<br />

makefsdata Perl script. This executable is included into the<br />

demonstration project located in apps\webserver\ directory to make it<br />

easier for the user to generate the httpd-fsdata.c fi le without the need<br />

to fi nd and install a Perl interpreter.<br />

More on uIP TCP/IP stack<br />

uIP TCP/IP stack was originally developed by Adam Dunkels of<br />

the Networked Embedded Systems Group at the Swedish Institute<br />

of Computer Science. Currently, is it part of the open source<br />

community and can be obtained freely from http://www.sics.<br />

se/~adam/uip. uIP TCP/IP stack includes some higher layer example<br />

applications such as web server, web client, Trivial File Transfer<br />

Protocol (TFTP), and DNS hostname server.<br />

uIP TCP/IP stack does not require a real-time operating system.<br />

However, there are versions of it ported to an open source FreeRTOS<br />

operating system and are available on the Internet. It is also<br />

ported to several other Renesas MCU devices. Sample code can be<br />

downloaded from the uIP web site.<br />

24


Usage considerations with uIP TCP/IP stack<br />

One consideration when using a uIP TCP/IP stack is that it<br />

supports only one TCP segment in transit. If uIP TCP/IP stack<br />

is used with a TCP receiver using a delayed acknowledgment<br />

algorithm, throughput performance can be poor. You can modify<br />

TCP acknowledgment behavior of your PC if you experience this<br />

condition with your default PC setup.<br />

More information can be found at http://support.microsoft.com/<br />

kb/328890. This situation is also discussed in the uIP TCP/IP<br />

reference manual.<br />

Another consideration is that the uIP TCP/IP stack supports one<br />

TCP and one UDP application at a given time. In this demonstration<br />

project, the HTTP web server application uses TCP and DHCP client<br />

runs on UDP. An application multiplexer layer based on connection<br />

port number can be added to the uIP TCP/IP stack to support multiple<br />

TCP or UDP applications.<br />

More on DHCP<br />

Dynamic Host Confi guration Protocol (DHCP) is a protocol used by<br />

networked devices to obtain IP addresses and other parameters<br />

such as default gateway, subnet mask, and an IP address of the<br />

Domain Name Server (DNS) from a DHCP server. The protocol is<br />

defi ned by RFC 2131. DHCP eases the management of the above<br />

tasks and ensures that all IP addresses on the network are unique<br />

and unused IP addresses are returned back to the IP address poll for<br />

reassignment for other devices joining the network.<br />

The demonstration project makes use of the dynamic mode of<br />

DHCP. In dynamic mode, a client is provided with an IP address and<br />

time duration in which this IP address is valid. This time duration is<br />

called lease time.<br />

DHCP operation<br />

There are four main messages exchanged between a DHCP client<br />

and a DHCP server during dynamic IP address assignment. They are<br />

shown in Table 1.<br />

Table 1: DHCP messages.<br />

Message From To Details<br />

DHCP<br />

Discovery<br />

DHCP<br />

Offer<br />

DHCP<br />

Request<br />

DHCP<br />

Acknowledge<br />

Client Server Client discovers DHCP servers and asks for<br />

an IP address.<br />

Server Client Server reserves and IP address and offers it<br />

to the client.<br />

Client Server Client tells all DHCP servers that it accepted<br />

the offer.<br />

Server Client Server initiates fi nal phase of the<br />

confi guration. This message includes the<br />

lease time and other option parameters.<br />

How to use DHCP client<br />

There are certain things to consider while using a DHCP client.<br />

The most important consideration is to ensure that each device<br />

on the network has a unique MAC address. DHCP servers assign<br />

IP addresses based on client MAC addresses. For end customer<br />

production devices the MAC address can be purchased from IEEE.<br />

Another consideration is how to know what IP address is assigned<br />

to a device. One way to fi nd this information is to query the DHCP<br />

server through its management interface. Figure 11 shows that the<br />

RSK board with MAC address 00:11:22:33:44:55 is assigned to an<br />

IP address of 192.168.1.101. On the other hand, the RSK board<br />

with MAC address 00:11:22:33:44:56 is given an IP address of<br />

192.168.1.100.<br />

Figure 11: DHCP client status information on the DHCP server.<br />

Debugging a system with a DHCP server can be tricky. Here are some<br />

recommendations. First, use of a network analyzer is a great help.<br />

Wireshark has been used throughout the development of this project.<br />

It is a PC-based network analyzer software. For more information on<br />

Wireshark, see http://www.wireshark.org.<br />

Second, the IP address of the PC Ethernet port used by the network<br />

analyzer must be on the same network and subnet with the DHCP<br />

server and its clients, e.g. the Renesas target board(s). This can be<br />

achieved by assigning a static IP address to the PC Ethernet port that<br />

is outside the IP addresses that can be given out by the DHCP server,<br />

but still making sure that network and subnet requirements are met.<br />

For example, in Figure 3 the DHCP server is confi gured with a start IP<br />

address of 192.168.1.100. Figure 4 shows that the PC Ethernet port is<br />

confi gured to use the192.168.1.2 and it is outside the range of the IP<br />

addresses that can be given to its clients by the server.<br />

References<br />

1. Group Hardware Manuals for the Renesas device on the RSK board.<br />

2. The uIP Embedded TCP/IP Stack, The uIP 1.0 Reference Manual, June 2006, Adam<br />

Dunkels, Swedish Institute of Computer Science<br />

3. IEEE 802.3 Ethernet, IEEE Standards Association, http://standards.ieee.org/<br />

getieee802/802.3.html<br />

4. HTTP – Hypertext Transfer Protocol. World Wide Web Consortium, http://www.<br />

w3.org/Protocols<br />

5. RFC 2131 Dynamic Host Confi guration Protocol, IETF, http://www.ietf.org/rfc/<br />

rfc2131.txt<br />

6. RFC 2132 DHCP Options and BOOTP Vendor Extensions, IETF, http://www.ietf.org/<br />

rfc/rfc2132.txt<br />

Website and Support<br />

Renesas Electronics Website: http://www.renesas.com/<br />

Inquiries: http://www.renesas.com/inquiry<br />

Quick HEW Demonstration<br />

Renesas Electronics America<br />

Renesas’ HEW demonstration product training module<br />

narrates the use of the High-performance Embedded<br />

Workshop (HEW), a key tool<br />

for developing software for<br />

embedded systems.<br />

www.digikey.ca/ptm<br />

www.digikey.ca/microcontroller<br />

25


ColdFire Ethernet for<br />

Diverse Applications<br />

by Eric Gregori, Freescale Semiconductor<br />

Ethernet has migrated from PCs to embedded<br />

systems, a much more constrained<br />

environment. It can bring a lot of capabilities<br />

if you’re careful about its implementation<br />

Embedded Ethernet<br />

Ethernet has become a reality for low-cost embedded systems. The<br />

Ethernet standard (IEEE 802.3) was originally designed for networking<br />

computers over local area networks (LAN), but it has since been<br />

adapted for other purposes. Today it has become so popular that<br />

it is hard to fi nd a PC or laptop without an Ethernet port. Now this<br />

capability is migrating to the embedded world, where the ColdFire ®<br />

family excels. The IEEE 802.3 specifi cation defi nes a mechanical/<br />

electrical connection between devices (physical layer) and a multinode<br />

addressable communications protocol (Media Access Control —<br />

MAC — layer).<br />

Ethernet physical layer<br />

The Ethernet physical layer (PHY) defi nes the physical connections<br />

between nodes. The 802.3 standard defi nes many physical layers,<br />

including everything from coaxial cable to fi ber optics. Through<br />

the years, the most common choice for this purpose has changed<br />

drastically from thick multi-strand cables with large connectors<br />

(called thicknet) to the small RJ-45 8-pin connector we use today.<br />

The common modern copper physical layer is referred to as<br />

100Base-TX (a type of 100Base-T). This copper-based twistedpair<br />

medium contains eight wires grouped in four twisted pairs.<br />

Two twisted pairs are used for communication in each direction.<br />

The cable is referred to as a<br />

category 5 (cat 5 for short). The<br />

RJ45 Jack<br />

category 5 standard defi nes a<br />

cable consisting of four twisted<br />

pairs capable of carrying<br />

frequencies up to 100 MHz.<br />

Pin 8<br />

Most Ethernet embedded devices<br />

have integrated MACs (discussed<br />

in the next section) with external<br />

PHY. ColdFire offers a sevenmember<br />

family of microcontroller<br />

Pin 1<br />

units (MCU) with integrated MAC/<br />

PHY called MCF5223x.<br />

Figure 1: The Modern Ethernet Jack.<br />

Most modern buildings and residences are wired using category<br />

5 cables for their PC networks and broadband, making this an<br />

ideal medium for distributed processing/sensing in a building or<br />

residential environment.<br />

Ethernet MAC layer<br />

The MAC protocol layer defi nes the communication that occurs over<br />

the physical layer. Ethernet is a multi-node protocol, so each node<br />

has a unique address. This address is defi ned in the MAC layer. In<br />

Ethernet communication, MAC addresses are 48 bits long (six bytes,<br />

or octets). The device’s MAC address never changes — usually it is<br />

programmed at the factory. The MAC address must be unique, so<br />

MAC addresses are managed and distributed by the IEEE.<br />

The MAC address, along with various other fields, is contained in<br />

the Ethernet MAC header. As the name implies, the header sits in<br />

front of the Ethernet packet. It contains the MAC address of the<br />

source node, the MAC address of the destination node, and a<br />

type field.<br />

Preamble<br />

Destination<br />

Address<br />

Figure 2: Ethernet MAC header.<br />

Source<br />

Address<br />

Frame<br />

Type<br />

Frame User Data<br />

FCS<br />

Checksum<br />

8 Bytes 6 Bytes 6 Bytes 2 Bytes 46 - 1500 Bytes 4 Bytes<br />

Ethernet can be used directly without any additional layers. It<br />

provides a simple point-to-point communication mechanism, with<br />

some error checking (FCS checksum). Ethernet by itself does not<br />

provide the high degree of communications robustness of which<br />

we have become accustomed. Additional layers are required to add<br />

features such as multiple ports, packet re-transmission, packet<br />

timeouts, and connections. These additional layers are defi ned by<br />

the seven-layer OSI model.<br />

Seven-Layer OSI model<br />

The seven-layer OSI model defi nes the functions of the various layers<br />

in a communication stack. The lowest layers (physical and MAC/data<br />

link layers) are traditionally implemented in hardware. The fi ve layers<br />

above the MAC/DDL are usually implemented in software.<br />

The network or IP layer (for a TCP/IP stack) provides an additional<br />

layer of addressing (IP addresses in the hexadecimal format of xx.xx.<br />

xx.xx) and multiplexing. Multiplexing splits a single communications<br />

channel into multiple time-divided communications channels (ports, in<br />

TCP/IP terminology).<br />

26


The transport layer adds the most critical feature to the<br />

communication stack. TCP (transmission control protocol) is one of<br />

the transport layers in TCP/IP. This layer is responsible for creating a<br />

virtual connection between two logical points (not nodes). The logical<br />

points are referred to as sockets. The socket’s API is actually defined<br />

by the session layer.<br />

Last, at the highest level, is the application layer. This application<br />

defines the common protocols used on the Internet: HTTP, SMTP, and<br />

TFTP. This layer can also be used for custom protocols.<br />

Movement up and down the stack is an area of inherent inefficiency<br />

in a communication stack. To improve efficiency, higher-performance<br />

stacks use pointers instead of copying the data multiple times (this is<br />

sometimes referred to as zero copy). Pointer arithmetic is significantly<br />

more efficient with a 32-bit core using true 32-bit registers. This is a<br />

big advantage for the ColdFire 32-bit architecture.<br />

In addition, extracting data from individual fields in a header can<br />

become a single-instruction operation by using advanced addressing<br />

modes with offset capability.<br />

Figure 3: Seven-layer OSI model.<br />

ColdFire family of microcontrollers<br />

The ColdFire family of microcontrollers is based on the 32-bit ColdFire<br />

cores. The ColdFire core is available in four varieties, each a superset<br />

of the core below it. The cores are completely scalable, with the<br />

differences consisting of additional instructions or add-on modules<br />

(for instance, MMU) and longer pipelines to increase frequency<br />

and performance for demanding applications. The current V1 core<br />

contains the base register and instruction set. The V2 core adds<br />

additional instructions and addressing modes to the V1 core, along<br />

with an optional eMAC (Enhanced Multiply/Accumulate unit).<br />

Figure 4: ColdFire cores: scalable instruction sets, features and performance.<br />

Advantage of a 32-bit architecture<br />

The true 32-bit architecture of ColdFire microcontrollers lends<br />

itself well to efficient communication stack data movement. In a<br />

communication stack such as TCP/IP, the packet comes in at the<br />

bottom of the stack and propagates up. Data to be sent starts at the<br />

top of the stack as a buffer, and then works its way to the bottom of<br />

the stack to be sent out as a packet.<br />

Figure 5: Seven-layer OSI model with communication stack overlaid on top.<br />

ColdFire Fast Ethernet Controller (FEC)<br />

The FEC module is the ColdFire interface to the Ethernet world. The<br />

FEC module is consistent from the highest-performance V4-corebased<br />

part all the way down to the V1 core. This consistency means<br />

that drivers written for one Ethernet-enabled ColdFire processor will<br />

work on any Ethernet-enabled ColdFire processor (memory allocation<br />

would be the biggest difference).<br />

The FEC module is a high-performance Ethernet engine with a very<br />

rich heritage. The FEC module started out in the MPC860T. This highperformance,<br />

Power Architecture-based processor quickly became<br />

a powerhouse in the Ethernet world, going into high-performance<br />

routers and telecommunication equipment. The MPC860T was so<br />

popular in the Ethernet world that if you make a call today, chances<br />

are that somewhere along the way the voice data of your call will<br />

pass through an MPC860T.<br />

The MPC860T came out in the mid-1990s. The FEC module has been<br />

tested and improved upon for over ten years in some of the highest<br />

performance Ethernet environments. The FEC module from the<br />

MPC860T is now in the ColdFire line of processors.<br />

ColdFire FEC features<br />

• Ethernet MAC is designed to support 10 Mbps and 100 Mbps<br />

Ethernet/IEEE 802.3 networks<br />

• IEEE 802.3 full-duplex flow control<br />

• Support for full-duplex operation (200 Mbps throughput)<br />

www.digikey.ca/microcontroller<br />

27


• <br />

<br />

• <br />

<br />

<br />

• <br />

<br />

<br />

<br />

<br />

<br />

<br />

• <br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

ColdFire TCP/IP stack<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

ColdFire TCP/UDP/IP stack features<br />

• <br />

<br />

• <br />

• <br />

<br />

• <br />

<br />

• <br />

<br />

• <br />

Figure 6: <br />

<br />

<br />

• <br />

• <br />

• <br />

• <br />

• <br />

• <br />

• <br />

• <br />

<br />

<br />

<br />

<br />

Figure 7: <br />

28


DHCP client<br />

The Dynamic Host Configuration Protocol (DHCP) is used to acquire<br />

network parameters at runtime. The DHCP protocol is defined in RFC<br />

2131 and RFC 2132. The stack runs a DHCP client which searches for<br />

a DHCP server (this is referred to as discovery).<br />

Packets are transferred using the UDP layer and BOOTP ports (67<br />

and 68). Because the IP stack does not have an IP address yet,<br />

discovery is done using strictly broadcast addresses. Included in the<br />

discovery packet is a unique transaction ID (xid). A listening DHCP<br />

server sends an offer message containing the xid sent by the client<br />

and the suggested network parameters, again using broadcast<br />

addressing. Encoded in the offer is a unique server ID. The client will<br />

use this server ID when sending a request packet back to the server,<br />

indicating that it accepts the network parameters that were offered.<br />

Finally the server ACK’s the client using its new IP address.<br />

DNS client<br />

The DNS client is used to communicate with the DNS (Domain Name<br />

Server). The purpose of the DNS system is to translate domain names<br />

into IP addresses. The DNS protocol is described in RFC 1035. DNS<br />

can use UDP or TCP, with port 53. The DNS protocol is stateless — all<br />

the information is contained in a single message. This message is<br />

fully documented in RFC 1035.<br />

Available examples and application notes<br />

All application notes mentioned in this article are available at www.<br />

freescale.com.<br />

HTTP web server and flash file system<br />

The HTTP web server and flash file system are described in detail in<br />

application note AN3455, ColdFire Lite HTTP Server.<br />

The features are:<br />

• HTTP 1.0 compliant server with connection persistence and<br />

multiple sessions<br />

• Multiple HTTP connections supported<br />

• Flash file system which supports both ColdFire internal flash and<br />

external SPI flash<br />

• Web pages can be updated in flash over Ethernet or built in at<br />

compile time<br />

• HTTP GET method supported, with a simple mechanism for<br />

adding other methods<br />

• Dynamic HTML (Hypertext Markup Language) support with<br />

replace and conditional tokens<br />

• Serial interface support for Dynamic HTML variables<br />

• Run-time and compile-time flash file systems<br />

• Long filename support with subdirectories<br />

• “DIR” command supported on serial interface<br />

• PC utilities for compressing compile-time and run-time<br />

downloadable images of multi-page web pages<br />

• PC utility for downloading run-time downloadable web page<br />

image through port 80 (to get through firewalls)<br />

• 32-byte ASCII key for web page download security<br />

UDP/TCP clients and servers — Example source code<br />

The ColdFire Lite stack project includes almost a dozen built-in<br />

usage examples. These examples are designed to highlight<br />

various features in the stack and demonstrate how to use them.<br />

The TCP/IP stack and RTOS, along with all the sample applications<br />

listed below, are discussed in AN3470, ColdFire TCP/UDP/IP Stack<br />

and RTOS.<br />

Code examples include:<br />

• ColdFire_Lite<br />

Barebones TCP/IP stack<br />

• ColdFire_Lite_RTOS<br />

How to use the RTOS application<br />

• ColdFire_Lite_TFTP<br />

TFTP server application<br />

• ColdFire_Lite_UDP_client<br />

UDP client application for UDP performance testing<br />

• ColdFire_Lite_UDP_server<br />

UDP server application for UDP performance testing<br />

• ColdFire_Lite_TCP_client<br />

TCP client application for TCP performance testing<br />

• ColdFire_Lite_TCP_server<br />

TCP server application for TCP performance testing<br />

• ColdFire_Lite_TCP_serial_client<br />

TCP to serial/serial to TCP client<br />

• ColdFire_Lite_TCP_serial_server<br />

TCP to serial/serial to TCP server<br />

• ColdFire_Lite_TCP_with_Web_Server<br />

Web (HTTP) server with dynamic HTML<br />

ColdFire_Lite_TCP_alarm<br />

The alarm demo application includes both PC-side and ColdFireside<br />

firmware. This code is an example of a remote sensor<br />

application, where a remote sensor periodically sends data over TCP<br />

to a host server.<br />

Figure 8: ColdFire TCP alarm.<br />

www.digikey.ca/microcontroller<br />

29


HTTP client firmware<br />

The HTTP client provides the ability to read web pages and XML data<br />

from the Internet using a ColdFire processor. The HTTP client uses the<br />

DHCP client to automatically acquire an IP address and other TCP/<br />

IP information, including the IP address of any DNS server. Then the<br />

HTTP client uses the DNS client to translate any user-provided URLs<br />

into IP addresses.<br />

The HTTP client uses the GET method to request a page from the<br />

server. Along with the GET request is the HTTP header. The HTTP<br />

header is hard-coded in the HTTP client via constant strings declared<br />

in the fi le emg_http_client.c.<br />

Wget command – An example of using the HTTP client<br />

The Wget command is a command often found in Linux distributions that<br />

transfer files using the HTTP protocol. The Wget command is a consolebased<br />

HTTP client. Using the menuing system provided by the ColdFire<br />

TCP/IP stack (explained in application note AN3470) and the HTTP client,<br />

Wget functionality can be added to the ColdFire TCP/IP stack.<br />

RSS/XML character data filter<br />

To extract the character data (the information you actually want to<br />

read) from the RSS stream, all the meta-text must be fi ltered out. Any<br />

valid HTML must be translated and processed. For instance, the HTML<br />

tag that causes a line break is . This would appear as &lt;br&gt;<br />

in the RSS stream. The fi lter must correctly translate &lt;br&gt; into a<br />

carriage return and line feed.<br />

Other HTML tags that are routinely embedded in character data<br />

include paragraph tags and image tags . In the stream<br />

these tags appear as &lt;p&gt; and &lt;img&gt; respectively. The<br />

paragraph tab can be translated to a carriage return and line feed,<br />

but the image tag must be ignored unless the embedded system can<br />

process images.<br />

The fi lter takes in an XML or RSS data stream and a list of tags. It<br />

outputs only the character data from the selected tags. The tag list is<br />

an array of pointers to those tag strings that need to be fi ltered.<br />

Normally the fi lter returns 0. When the fi lter processes the “>” in a tag<br />

in the list, it returns to the fi lter array the index + 1 for the tag that it<br />

found. Example: after detecting a tag in an RSS or XML stream<br />

the fi lter will return 1. After detecting a tag in a stream<br />

the fi lter will return 2. Normally the fi lter returns 0.<br />

Example embedded appliance — RSS/XML feed reader<br />

The RSS/XML feed reader is an embedded appliance that allows<br />

users to display and even hear real-time content from the World Wide<br />

Web. The purpose of the embedded appliance is to provide instant<br />

real-time information without booting a PC. There are many types<br />

of real-time data available on the web; weather data (current and<br />

forecast), online DVD queue data, online auction data, sports score<br />

data, real-time news data, real-time stock data, medical and health<br />

data, and much more. All this data is available on the web as either<br />

an XML feed or an RSS feed. This appliance connects to the web, gets<br />

the desired feed, and parses the text information or character data<br />

from the feed. That data is displayed on the LCD, sent to the serial<br />

port, and spoken through the speech processor.<br />

For complete details on the RSS feed reader, please see AN3518,<br />

Advanced ColdFire TCP/IP Clients.<br />

Figure 9: The RSS/XML feed reader.<br />

M52233DEMO board from Freescale Semiconductor<br />

The M52233DEMO board is a reference board used to evaluate<br />

Freescale’s ColdFire MC52233 processor. The inexpensive board<br />

includes a serial port, USB BDM debug port, and Ethernet port. The<br />

board along with the free CodeWarrior tools (up to 128K of fl ash)<br />

are all you need to get up and running on your Ethernet projects.<br />

Freescale provides a free public source TCP/IP stack on their<br />

website. This TCP/IP stack is what the application in this article<br />

runs on. The ColdFire TCP/IP stack is documented thoroughly in<br />

application note AN3470.<br />

The demo board includes a 40-pin header fi ving the use access to<br />

most of the Coldfi re signals, a 3-axis accelerometer, a potentiometer,<br />

and two user buttons.<br />

LCD<br />

The parallel LCD is a 4 × 20 character display that uses the standard<br />

Hitachi instruction set. The LCD is used in its 4-bit mode, requiring<br />

only six connections to the micro, the 4-bit data bus, a clock signal<br />

(E), and a register select line (RS). The fi rmware also includes a library<br />

to drive the LCD.<br />

30


Voice synthesizer<br />

The RC Systems V-Stamp voice synthesizer is an easy-to-use, textto-speech<br />

processor. The V-Stamp is a fully self-contained module,<br />

requiring only power, a speaker, a resistor, two capacitors, and a serial<br />

connection to an embedded system. The V-Stamp communicates with<br />

the embedded system using a UART. The module automatically sets<br />

its baud rate to that of the embedded system. From both a hardware<br />

and firmware point of view, there is very little work required to add<br />

the V-Stamp module to the RSS feed reader.<br />

Firmware<br />

Figure 11: HTTP communication protocol.<br />

Figure 10: Firmware block diagram.<br />

HTTP<br />

HTTP is the communication protocol of the World Wide Web. HTTP is<br />

used to transfer web pages (hypertext documents) across the Internet.<br />

An HTTP connection has two parts, the HTTP client (web browser) and<br />

the HTTP server. The HTTP client is used to receive and view the web<br />

pages. The HTTP server is used to store, organize, and transfer the<br />

web pages.<br />

HTTP is defined by RFC 1945 and RFC 2616. RFC 1945 defines<br />

HTTP 1.0, and RFC 2616 defines the latest version, HTTP 1.1.<br />

HTTP is a request-response protocol. The client requests a web<br />

page from the server and the server responds with the web page<br />

contents. HTTP can be used to send any type of data, including<br />

binary data. The client requests a file using the GET method (HTTP<br />

is an ASCII protocol). The server responds with an HTTP header<br />

followed by the file contents. Within the request, the version number<br />

of the HTTP is also embedded in ASCII. This tells the server the<br />

limitations of the client.<br />

Really Simple Syndication (RSS)<br />

RSS feeds are available everywhere on the Internet. The idea behind<br />

the RSS feed is to convey dynamic textual information in a simple<br />

standard format.<br />

RSS originated in 1999 with the idea of providing content in a<br />

simple easy-to-understand format. Instead of describing a complete<br />

document in the way that HTML does, RSS feeds use XML to describe<br />

data. An RSS feed is simply an XML document containing data. The<br />

methods used to convey the data within the XML document are<br />

described in the RSS 2.0 specification. All RSS files must conform<br />

to the XML 1.0 specification. RSS feeds generally use HTTP as the<br />

transport mechanism.<br />

Extensible Markup Language (XML)<br />

The XML 1.0 specification can be found at www.w3.org/TR/REC-xml/.<br />

XML is a language used to describe and parse information. It is very<br />

similar to structures in C.<br />

Data is organized into elements, with each element assigned to a<br />

tag. The data in the element is surrounded by a start tag and an<br />

end tag. The name in the start and end tags defines the element’s<br />

type. The end tag name must be the same as the start tag name,<br />

except the end tag is identified by the addition of a “/” before the<br />

tag name.<br />

Tags<br />

Here is an example of an XML tag:<br />

Advanced ColdFire TCP/IP Clients<br />

TITLE is the type, is the start tag, and is the end<br />

tag. The data is between the tags. Just like a C data structure, the<br />

data is associated with the type. The data between the start and end<br />

tags is referred to as the element’s content.<br />

www.digikey.ca/microcontroller<br />

31


Elements can contain other elements, which provide a method of<br />

grouping data of different types under a single name. Just like a C<br />

structure, the particular piece of data is referenced by specifying a<br />

path to the data. a single name. Just like a C structure, the particular<br />

piece of data is referenced by specifying a path to the data.<br />

<br />

<br />

ColdFire HTTP Server<br />

ColdFire TCP/IP Stack<br />

ColdFire USB Stack<br />

<br />

<br />

Special characters and escape sequences<br />

The “&”, “” characters are special XML characters.<br />

They are used as indicated above, to defi ne XML tags and escape<br />

sequences. Escape sequences are a method of specifying a character<br />

using a code, as opposed to using a single symbol. Escape sequences<br />

start with an ampersand (&) and end with a semicolon(;).<br />

Because XML ordinarily uses these characters for special functions,<br />

here is how to have them appear in XML data:<br />

• “” is indicated using the escape sequence &gt;<br />

• “&” is indicated using the escape sequence &amp;<br />

CDATA sections: the exception to the rule<br />

All rules have exceptions, and in XML it’s the CDATA section. Any text<br />

specified in a CDATA section is ignored by the XML parser, allowing the<br />

use of special characters without the need for escape sequences. A<br />

CDATA section starts with a “” string. Anything between the brackets is ignored by the XML parser.<br />

• <br />

• &lt; ]]><br />

• Because the text between the brackets is ignored by the XML<br />

parser, both the tag and the escape sequence are not parsed, but<br />

instead are interpreted as text or character data.<br />

Finding text or character data in an XML document<br />

From the XML 1.0 specifi cation: “all text that is not markup<br />

constitutes the character data of the document.” That would include<br />

all the text between the brackets in a CDATA section, and any text not<br />

between “” brackets in the main body. Escape sequences in<br />

the main body represent a single piece of character data.<br />

To fi lter out the character data from an XML document, simply remove<br />

all tags as well as “” brackets. Then translate the escape<br />

sequences into actual characters.<br />

Sample XML file<br />

In the sample XML document below, notice how data is encapsulated<br />

by tags, and how the tag names describe the data. It even looks like<br />

a C structure. To fi nd the desired data in an XML document, simply<br />

look for the start and end tags with the name of the type of data you<br />

are looking for. The actual data associated with the desired type is<br />

between the tags.<br />

http://www.weather.gov/data/current_obs/KUGN.xml<br />

<br />

- <br />

NOAA’s National Weather Service<br />

http://weather.gov/ <br />

- <br />

http://weather.gov/images/xml_logo.gif<br />

NOAA’s National Weather Service<br />

http://weather.gov<br />

<br />

15 minutes after the hour<br />

60<br />

Chicago / Waukegan, Waukegan Regional Airport, IL<br />

<br />

KUGN<br />

42.420<br />

-87.870<br />

Last Updated on Jul 28, 10:52 am CDT<br />

<br />

Sat, 28 Jul 2007 10:52:00 -0500 CDT<br />

<br />

Overcast<br />

73 F (23 C)<br />

73<br />

23<br />

81<br />

From the Northeast at 13 Gusting to 21 MPH<br />

<br />

Northeast<br />

30<br />

12.65<br />

21<br />

29.98” (1014.1 mb)<br />

1014.1<br />

29.98<br />

67 F (19 C)<br />

67<br />

19<br />

73 F (23 C)<br />

73<br />

23<br />

NA<br />

NA<br />

NA<br />

10.00<br />

http://weather.gov/weather/images/fcicons/<br />

<br />

ovc.jpg<br />

http://www.weather.gov/data/obhistory/KUGN.html<br />

<br />

http://www.nws.noaa.gov/data/METAR/KUGN.1.txt<br />

http://weather.gov/disclaimer.html<br />

http://weather.gov/disclaimer.html<br />

http://weather.gov/notice.html<br />

<br />

32


Drawback of XML documents<br />

The problem with XML documents is the flexibility of the tag names.<br />

The creator of the XML document can use any name to describe the<br />

data. To avoid confusion, a standard is required to standardize the tag<br />

names, and the way that data is associated with a specific type. That<br />

standard exists and is called the RSS specification.<br />

The RSS specification<br />

RSS is a dialect of XML — it embeds HTML constructs into the XML<br />

architecture. RSS also defines a set group of elements and a general<br />

template using those elements. There are many elements defined<br />

in the specification, but here we will concentrate on the elements of<br />

interest for the RSS appliance.<br />

Typical RSS file<br />

<br />

The name of the channel<br />

URL to the HTML website corresponding to this<br />

channel<br />

Text describing the channel<br />

<br />

< title>Item1 Title<br />

URL of item 1<br />

Text for item 1<br />

<br />

<br />

Item2 Title<br />

URL of item 2<br />

Text for item 2<br />

<br />

<br />

The organization of the RSS file can be compared to a newspaper.<br />

The channel is the name of the paper, the items are the articles in the<br />

paper, the titles are the titles of the articles, and the descriptions are<br />

the text of the articles.<br />

Sample RSS file<br />

The sample RSS file given here contains the same data as the sample<br />

XML file above. Notice the structure and tag names. The RSS standard<br />

defines the title and description tag names, and those tags contain<br />

the data we want. All RSS 2.0 compliant feeds will contain title and<br />

description tags.<br />

http://www.weather.gov/data/current_obs/KUGN.rss<br />

<br />

- <br />

- <br />

Weather at Chicago / Waukegan, Waukegan Regional Airport,<br />

IL - via NOAA’s National Weather Service<br />

http://www.weather.gov/data/current_obs/<br />

Sat, 28 Jul 2007 16:32:11 UT<br />

60<br />

Weather conditions from NOAA’s National Weather<br />

Service.<br />

en-us<br />

robert.bunge@noaa.gov<br />

w-nws.webmaster@noaa.gov<br />

- <br />

http://www.weather.gov/images/xml_logo.gif<br />

NOAA - National Weather Service<br />

http://www.weather.gov/data/current_obs/<br />

<br />

- <br />

Overcast and 73 degrees F at Chicago / Waukegan, Waukegan<br />

Regional Airport,IL<br />

http://weather.noaa.gov/weather/current/KUGN.html<br />

- <br />

- <br />

]]><br />

Winds are Northeast at 13 Gusting to 21 MPH. The pressure is 29.98”<br />

(1014.1 mb) and the humidity is 81%.<br />

The heat index is 73. Last Updated on Jul 28, 10:52 am CDT.<br />

<br />

Sat, 28 Jul 2007 10:52:00 -0500 CDT<br />

<br />

<br />

<br />

RSS/XML character data filter<br />

To extract the character data (the information you actually want<br />

to read) from the RSS stream, all the meta-text must be filtered<br />

out. See the previous section, “RSS/XML Character Data Filter,” for<br />

more information.<br />

RSS/XML character data filter state machine<br />

The character data filter is implemented as a finite state machine.<br />

The state machine uses only two global variables, a state variable<br />

and a FILO. The purpose of the FILO is to store characters. Each byte<br />

entered into the filter is shifted left into the FILO. Therefore the most<br />

recent character is at location filo_buff[FILO_BUFF_SIZE–1]. The FILO<br />

buffer size must be larger than the largest tag name expected. The<br />

FILO buffer size is set with the FILO_BUFF_SIZE macro.<br />

#define FILO_BUFF_SIZE 32<br />

States:<br />

STATE_ZERO<br />

STATE_TAGSEARCH<br />

STATE_INTAG<br />

STATE_PRINT<br />

STATE_SKIP<br />

STATE_SKIP_NON_ASCII<br />

STATE_SKIP_SPACE<br />

STATE_CDATA<br />

STATE_CDATA_PRINT<br />

STATE_CDATA_SKIP_AMP<br />

STATE_SKIP_INTAG<br />

STATE_IN_AMPERSAND<br />

Global Variables:<br />

unsigned char filo_buff[FILO_BUFF_SIZE];<br />

unsigned char state;<br />

unsigned char EMG_rss_text_filter(unsigned char data, unsigned char<br />

**tag_filter)<br />

www.digikey.ca/microcontroller<br />

33


Figure 14: Character data fi lter usage.<br />

Using the RSS/XML feed reader<br />

Using the RSS/XML feed reader fi rmware is easy:<br />

Figure 12: RSS/XML datafl ow diagram.<br />

The fi lter takes in an XML or RSS data stream and a list of tags.<br />

It outputs only the character data from the selected tags. The<br />

tag list is an array of pointers to those tag strings that need to<br />

be fi ltered.<br />

Normally the fi lter returns 0. When the fi lter processes the “>” in a<br />

tag in the list, it returns into the fi lter array the index+1 for the tag<br />

that it found. Example: after detecting a tag in an RSS or<br />

XML stream the fi lter will return 1. After detecting a <br />

tag in a stream the fi lter will return 2. The fi lter returns 0 if a tag is<br />

not found.<br />

Const unsigned char *tag_filter[] =<br />

{<br />

{(const unsigned char *)”title”},<br />

{(const unsigned char *)”description”},<br />

{(const unsigned char *)””}<br />

};<br />

Figure 13: Sample tag_fi lter pointer array.<br />

1. Set the variable url to the URL or to the desired RSS or XML server.<br />

static const unsigned char url[] =<br />

“http://www.weather.gov/data/current_<br />

obs/KUGN.rss”;<br />

2. Set the tag_fi lter[] to the type of data you want to display.<br />

For RSS feeds, and would be a fi rst choice.<br />

For XML feeds, this could be any tag name depending on the<br />

information.<br />

const unsigned char *tag_filter[] =<br />

{<br />

{(const unsigned char *)”title”},<br />

{(const unsigned char *)”description”},<br />

{(const unsigned char *)””}<br />

};<br />

3. Set the character buffer size large enough to collect your<br />

fi ltered data.<br />

#define RSS_CHARACTER_BUFF_SIZE2048<br />

4. Compile the project and fl ash it to the board.<br />

After the TCP/IP stack comes up, these actions occur:<br />

1. The DHCP client automatically acquires an IP address and DNS IP<br />

address.<br />

2. It displays and speaks a title screen.<br />

3. It connects to the server specifi ed in the URL.<br />

4. The status of the connection is displayed and spoken.<br />

5. The fi le is downloaded from the server using the HTTP client.<br />

6. After the connection closes, the fi le is displayed and spoken.<br />

7. The RSS/XML feed reader sleeps, waiting for either SW1 or SW2<br />

to be pushed. When that happens, a connection is initiated to<br />

the server specifi ed in the URL that starts the download/display/<br />

speak process all over again.<br />

34


XML Streams<br />

For XML streams, the EMG_rss_text_fi lter() return value is used<br />

to determine which tag is applied to the data that comes after the<br />

tag. This allows another const array containing more descriptive<br />

names to be used to describe the data from the tag. Simply use<br />

the EMG_rss_text_fi lter() return value–1 to index into a descriptive<br />

name array, then send the indexed string into the character buffer<br />

before leaving the RSS callback function. The XML fi lter will then<br />

place the data from the tag in the character fi lter directly after the<br />

descriptive name.<br />

Conclusion<br />

Adding Ethernet to embedded products provides a level of<br />

connectivity never before available in the embedded space.<br />

Embedded devices can be networked together using the same<br />

cables and hardware used by the industry to connect PCs together.<br />

The embedded device can become part of the PC network.<br />

Ethernet and TCP/IP enable the embedded device to connect to<br />

the ultimate network, the Internet. After the embedded device<br />

is connected to the Internet it is available to the world, and<br />

controllable or viewable from anywhere. The possibilities are<br />

endless, from remote monitoring and control to distributed control,<br />

and even real-time, world-wide data presentation through the<br />

RSS feed reader.<br />

i.MX35 Processor<br />

Freescale Semiconductor<br />

The i.MX35 processor is the latest series from Freescale.<br />

This chip includes an increased level of integration and<br />

support, while maintaining low-power requirements.<br />

Digi-Key’s product<br />

training module<br />

featuring the<br />

i.MX35 processor<br />

aids purchasers<br />

in understanding<br />

the many benefi ts<br />

of integrating this<br />

device into designs<br />

and projects. Applications for this processor include<br />

portable navigation devices, printers, and eBooks to<br />

name a few.<br />

www.digikey.ca/ptm<br />

Kinetis <strong>Microcontroller</strong>s<br />

Design Potential. Realized.<br />

• The fi rst broad-market mixed signal MCU family based on<br />

the ARM ® Cortex-M4 core<br />

• One of the most comprehensive ARM enablement portfolios<br />

in the industry<br />

• Over 200 pin-, peripheral- and software-compatible MCUs<br />

with exceptional performance, memory and feature scalability<br />

• Innovative 90 nm thin-fi lm-storage fl ash technology<br />

with FlexMemory delivering high-endurance EEPROM<br />

• Ultra-low-power performance and rich mixedsignal<br />

integration<br />

Kinetis Family Positioning<br />

K10 Family: 32 KB to 1 MB, ultra-low power, advanced mixed signal,<br />

touch sensing, CAN<br />

K20 Family: 32 KB to 1 MB, ultra-low power, advanced mixed signal,<br />

touch sensing, CAN, USB OTG<br />

K30 Family: 32 KB to 512 KB, ultra-low power, advanced mixed signal,<br />

touch sensing, CAN, segment LCD<br />

K40 Family: 32 KB to 512 KB, ultra-low power, advanced mixed signal,<br />

touch sensing, CAN, USB OTG, segment LCD<br />

K60 Family: 256 KB to 1 MB, ultra-low power<br />

www.digikey.ca/freescale-mcu<br />

www.digikey.ca/microcontroller<br />

35


Your MCU is Just Starting<br />

to be Connected<br />

by Tom Starnes, Industry Analyst, Objective Analysis<br />

If “the network is the computer,” then<br />

connectivity is what empowers—or limits—<br />

your MCU application. This is an area that<br />

continues to evolve rapidly.<br />

<strong>Microcontroller</strong>s (MCUs) have utilized serial transmissions<br />

practically from the onset, but the purpose and elegance of those<br />

channels have evolved greatly over the last 30 years. The word<br />

“connectivity” has taken on new prominence in most applications<br />

in the new century, driving on-chip support for networking and<br />

even wireless communications from the microcontroller. The<br />

advantages of more advanced connectivity and the ease with<br />

which it can be obtained make it well worthwhile to take a renewed<br />

look at how your end-application can make use of broader<br />

communications capabilities.<br />

Begin with the basics<br />

In the 1970s, as MCUs were fi rst emerging, UARTs (universal<br />

asynchronous receiver-transmitters) fi rst brought a pre-confi gured<br />

serial port to microprocessors and microcontrollers. UARTs and<br />

synchronous-capable USARTs were largely used to perform simple<br />

data communications. UARTs and USARTs were added to the MCU<br />

as the transistor budget allowed, and serial communication became<br />

more attractive.<br />

Soon, the need was determined to more tightly connect the central<br />

brain of the MCU with nearby peripherals that remained separate<br />

from the MCU due to their complexity, uniqueness, or electrical<br />

characteristics that made them less practical to integrate on-chip. A<br />

serial connection may have been slower than transmitting over the<br />

parallel bus, but it conserved valuable pins (even in the 8 bit era)<br />

and made it easier to use peripherals from a different, perhaps more<br />

specialized, vendor than the controller manufacturer. This gave rise<br />

to the various standard serial modules found in great numbers on<br />

today’s MCUs:<br />

• Philips’ I 2 C (Inter-Integrated Circuit)<br />

• Motorola’s faster SPI (Serial Peripheral Interface)<br />

• Philips’ fairlyspecifi c I 2 S (Inter-IC Sound)<br />

• Motorola’s SCI (Serial Communications Interface)<br />

Tradeoffs between speed and complexity may take a back seat to<br />

how many devices are on the channel and exactly which interface<br />

the desired peripheral supports. Generally, such serial interfaces are<br />

intended to connect only with other chips on the circuit board, often in<br />

a master-slave relationship. The SCI, often bundled with these serial<br />

ports, is really just a UART and more likely to provide a little longer<br />

reach. Buses like the I 2 C, SPI, and I 2 S are used to connect with nearby<br />

peripherals such as E2PROMs, real-time clocks, memory cards<br />

interfaces, analog-to-digital converters, digital-to-analog converters,<br />

sensors, camera interfaces, and audio codecs. For most of today’s<br />

MCUs, the existence of SCI, SPI, I 2 C, and similar serial ports are more<br />

of a requirement than a differentiating feature.<br />

Automotive drivers<br />

More sophisticated, frame-based serial communications were<br />

fi rst driven onto MCUs with the advent of CAN (Controller-Area<br />

Network). In the 1980s, Robert Bosch GmbH initiated CAN as a<br />

means for microcontrollers to communicate among themselves in<br />

an automobile, a platform where numerous MCUs were used. This<br />

harsh environment required robustness and a strict protocol. Since<br />

the number of potential network end-points was growing quickly,<br />

the need for a specifi c host or master could be limiting. Yet, reliable<br />

communications between disparate and optional controllers in the<br />

vehicle have greatly improved the operating conditions of the vehicle<br />

and have become a necessity for engine control, safety systems, and<br />

diagnostics. With the automotive industry’s support, the CAN network<br />

and CAN peripheral chips took hold.<br />

In the 1990s, CAN peripherals started appearing on-chip in MCUs<br />

destined for automotive applications, about the time the protocol<br />

started evolving. While other networks have also found some places<br />

in the automobile for specifi c applications, CAN still forms the<br />

backbone of most automotive systems. CAN has also found a home<br />

in industrial applications, with their similarly harsh environments and<br />

noisy conditions and in medical instruments where special integrity<br />

requirements are highly valued.<br />

CAN and MCUs were mad for each other. CAN was developed to let<br />

the systems that MCUs comprised communicate with each others.<br />

Since automotive applications are the inspiration for much of the<br />

design of MCUs, CAN modules are a natural circuit to include in MCUs.<br />

36


Computer connectivity<br />

The tremendous growth of the personal computer (PC), accompanied<br />

by Ethernet (see Figure 1) and the Internet, took place somewhat<br />

outside of the microcontroller industry but is having a heavy influence<br />

on it. The PC made de facto standards of TCP/IP, Ethernet, and<br />

Wi-Fi for long distance data communications with servers, email,<br />

the Internet, databases, and other systems. The need for system<br />

inter-activity drove TCP/IP and Ethernet to be the backbone of data<br />

communications, even supplanting the circuit-switched telephone<br />

network to a large degree, and attracting creative minds to make the<br />

protocol work for nearly every application. The utility of TCP/IP made it<br />

quite popular and the protocol stack became a well-honed standard,<br />

economies of scale dramatically drive down the prices of chips and<br />

software down.<br />

The ubiquity of the protocol and some confluence of Metcalfe’s<br />

Law and Moore’s Law, has opened untold opportunities for<br />

electronic system connectivity. Whether it is refrigerators reporting<br />

food shortages to the grocery store or air conditioning systems<br />

taking a break during peak electricity rate periods, networks,<br />

Ethernet, and TCP/IP are being employed in every conceivable<br />

application for machines to communicate with hosts, servers,<br />

directly to other machines, hubs, remote monitors, and to control<br />

centers manned or unmanned.<br />

<strong>Microcontroller</strong> vendors have responded by providing Ethernet<br />

controllers on their MCUs (although it took some time for the transistor<br />

budget to free up) and for OEMs to give serious consideration to<br />

Ethernet as a connectivity option on traditional MCU-based systems.<br />

Today the benefits are difficult to ignore. From software updates<br />

to remote monitoring to long-term customer services,<br />

when TCP/IP brings the Internet to the edge of<br />

the board for a small price adder, the<br />

option can be very attractive. If<br />

nothing else, access to the<br />

Internet gives essentially<br />

unlimited range to<br />

the control or<br />

management of<br />

the system.<br />

Figure 1: Ethernet cable.<br />

The ubiquitous USB<br />

The PC is also responsible for the great popularity of the USB<br />

(Universal Serial Bus). There used to be discussions of whether USB<br />

(Figure 2) would supplant other local connectivity<br />

ports on the PC, especially the spaceconstrained<br />

laptop, but it did not take very<br />

long for the discussion to turn to “how<br />

many USB ports can we put on<br />

this” Once USB ports and<br />

drivers became integral to<br />

the PC and a few devices<br />

converted over to the<br />

convenient standard,<br />

USB caught on<br />

like wildfire.<br />

Figure 2: USB connector.<br />

Soon, MCU-controlled devices such as the mouse, keyboard, and<br />

similar input devices, switched over to USB connections. Printers,<br />

modems, and other output devices made the change, abandoning<br />

interfaces with origins in the mainframe era. USB evolved to be faster<br />

(Table 1), making it more practical for hard drive interfaces. New form<br />

factors put flash memory on a thumb-sized portable storage device<br />

that easily plugs into many hosts. USB also became an intermediary<br />

and a “dongle” port where other connectivity devices can plug in,<br />

such as Ethernet, Bluetooth, Wi-Fi, and memory card adapters. At<br />

some point, the convenience of the USB port drew MCU vendors<br />

to put their own MCU evaluation boards and debugging ports on<br />

USB-enabled cards.<br />

Table 1: USB versions.<br />

Version Mbps Grade Comment<br />

USB 1.1 1.5 low-speed mice, keyboards<br />

12 full-speed printers<br />

USB 2.0 480 high-speed hard drives<br />

USB 3.0 5000 super-speed new connector, emerging<br />

USB gained additional popularity as its facility for supplying current<br />

to attached devices started to be exploited. It is possible to draw<br />

100 mA at 5 V (up to 500 mA also accommodated), which is more<br />

than enough to power numerous applications without an additional<br />

power source. With the slightest effort, this current can recharge<br />

the battery of a truly portable handheld device. This allows USB to<br />

perform the dual functions of transmitting data as well as supplying<br />

power – all with a single cord and connector.<br />

MCUs are convenient for operating the USB port for transmitting<br />

data and even for managing a recharging circuit. While the latter<br />

is usually left to the system engineer to design, integrating a USB<br />

controller onto the MCU eliminates an additional chip in the system.<br />

The cost is minimal and most of the software is readily available<br />

and prepackaged.<br />

The distinction between host (master), device (slave), and the<br />

swings-both-ways, On-The-Go (OTG) varieties of USB controllers<br />

must be considered when picking an MCU with USB capability, but<br />

more USB modules and stacks can support any role the controller<br />

must play. It’s another dimension of USB that should be narrowed<br />

down (along with speed grade and, eventually, physical connector<br />

style) when evaluating how the technology can expand an<br />

application’s utility.<br />

Less wire<br />

The ultimate in connectivity and<br />

communication would require no physical<br />

contact. Wireless communications,<br />

be it using Bluetooth, ZigBee, Wi-Fi,<br />

near-field communications (NFC), or<br />

similar technologies, are robust enough to<br />

link up between devices or with a network or<br />

the Internet without much trouble. Breaking the<br />

tether avoids certain hassles but also removes<br />

the benefit of getting electricity to the device, so<br />

there are some tradeoffs in going wireless. Also,<br />

the nature of radio circuits limits just how much<br />

www.digikey.ca/microcontroller<br />

37


these can be integrated onto the mostly-digital MCUs, but the vendors<br />

are still working to get closer to more compact and well-blended<br />

with wireless systems. Range, EMI, and security are other issues to<br />

consider in selecting the radio air interface.<br />

In industrial applications, for instance, having wireless<br />

controllers, especially in a mesh network, means that to<br />

move some equipment or add a sensor on a factory floor may<br />

mean just placing the equipment where it is needed. With a<br />

wireless network, no new cables need to be laid out or routers<br />

reconfigured. The network self-discovers the new equipment (and<br />

probably doesn’t care if it was only moved). If a unit fails, it simply<br />

falls off the grid and the rest of the network continues without it,<br />

though hopefully a flag is raised.<br />

Consumer explosion<br />

As mentioned, many forms of communications have become stand-outs<br />

and true standards in recent years. The high volume of digital consumer<br />

electronics has become a significant factor in establishing such<br />

standards. While CAN is more under-the-hood, USB and Ethernet are far<br />

more visible. The phenomenal boom – and churn – in digital still cameras,<br />

MP3 players and cellular phones—in tandem with the desire to transfer<br />

large amounts of data between PCs, TVs, printers, and the Internet—has<br />

caused an explosion in the need for universal connectivity.<br />

This explosion of consumer electronics needing connectivity opened<br />

huge opportunities for chip vendors to supply vast quantities of<br />

chips and programmers to write the protocol stacks to support the<br />

standards. Lower costs and off-the-shelf software made it even easier<br />

to connect consumer devices in more ways.<br />

<strong>Microcontroller</strong>s will hook you up<br />

<strong>Microcontroller</strong> vendors have been taking care of your<br />

connectivity and communications needs. More and more serial<br />

channels, communications methods, and networking peripherals have<br />

been brought into the MCU as the market has called for it. Along with<br />

the hardware implementation, the chip vendors have been assembling<br />

the software that makes it work. Third-party software vendors step<br />

up to the plate to offer improved, more universal, customizable,<br />

and specialized communications software and protocol stacks. The<br />

result is a relatively easy and cost-effective means of adding greater<br />

connectivity to MCU-based equipment.<br />

The more advanced communications protocols require more<br />

horsepower from the processor than a little bit-banging does or a<br />

UART. Some can take advantage of additional RAM for buffering<br />

and forming packets. Some can use Direct Memory Access (DMA)<br />

techniques to block-transfer strings of data to other parts of the<br />

system. The more advanced MCUs typically have more advanced<br />

communications capabilities. However, some advanced connectivity<br />

is available on 16-bit and 8-bit MCUs, as well. Most vendors have<br />

evolved with their markets, so your favorite architecture probably<br />

has a selection of MCUs with a peripheral on board to implement the<br />

technology of your choice.<br />

In my opinion, the best bet for exotic network and communications<br />

will be with 32-bit MCUs. They have the performance, the fl exibility,<br />

and the memory space to handle the code, and they are more likely<br />

to be in markets where overall performance is important, and where<br />

connectivity is a must rather than a luxury. This also means the 32-bit<br />

MCUs will keep up with heavy communications traffi c. However, 32-bit<br />

MCUs are not as expensive as one might believe. The price difference<br />

from a comparably-equipped 8-bit MCU is hardly noticeable.<br />

The established architectures have a good range of MCUs with<br />

CAN peripherals. Namely Renesas, Freescale, Texas Instruments,<br />

STMicroelectronics, and Microchip all have suitable solutions for<br />

this market.<br />

When it comes to USB, almost any vendor has a good range of MCUs<br />

with USB connectivity. USB does not weigh down 8-bit MCUs, and<br />

16-bit controllers should handle USB well.<br />

Ethernet has been appearing on MCUs more frequently the last<br />

few years, and has increasing promise as the Internet becomes<br />

a backbone for all things electronic. We are consistently seeing<br />

suppliers provide solutions with both MAC and PHY integrated on chip.<br />

There are a few MCUs containing an array of communications<br />

facilities. To highlight one solution, ARM-based Stellaris line from<br />

Texas Instruments has MCUs with several serial peripherals all<br />

on-chip including: two CAN 2.0 A/B controllers, a USB 2.0 Full-<br />

Speed Host/Device/OTG module, a 10/100 Ethernet MAC/PHY with<br />

hardware-assist to synchronize industrial networks via the IEEE 1588<br />

Precision Time Protocol, two SSI/SPI controllers, two I 2 C interfaces, an<br />

I 2 S interface, and three UARTs.<br />

Is your application suffi ciently connected for tomorrow<br />

Technical and Design Support Services<br />

Digi-Key offers live technical support 24/7 via telephone, e-mail<br />

and live web chat. Digi-Key’s 130 technicians on staff are<br />

trained by manufacturers to answer product-specifi c questions.<br />

Additionally, these technicians cross-reference part numbers,<br />

assist customers in choosing products, research and aid in<br />

selecting new product, and provide access to in-depth productspecifi<br />

c information as well as specifi cations and performance<br />

data on new products.<br />

Digi-Key’s Design Support Services (DSS) team of application<br />

engineers and technicians provides general information and<br />

complimentary project-specifi c assistance. DSS provides service<br />

to engineers ranging from one-time contacts regarding product<br />

recommendations to ongoing prototype-to-production design<br />

support. DSS strives to guide the customer through the design<br />

process while achieving the best solutions and, ultimately,<br />

streamlining the design cycle. The DSS team provides support<br />

and advice on system design, aids with product selection and<br />

development tools, and provides assistance with other applicable<br />

design issues. Additionally, members of the DSS team produce<br />

application notes, webinars and instructional videos. The DSS team<br />

is available from 8:30 a.m.-5:00 p.m. CST via telephone, e-mail<br />

and web-conferencing software.<br />

38


Are you a <strong>Microcontroller</strong> Solution Expert Submit your<br />

answers to find out and automatically be entered for<br />

a chance to win a Microchip PIC18 Starter Kit or an F1<br />

Evaluation Platform!<br />

The MPLAB ® Starter Kit for<br />

PIC18F MCU functions as a USB<br />

mouse, joystick or mass storage<br />

device all using the on-board<br />

capacitive touch sense pads. It<br />

includes a MicroSD memory<br />

card, potentiometer, acceleration<br />

sensor, and an OLED display. It is<br />

completely USB-powered.<br />

The F1 Evaluation Platform<br />

is a simple development tool<br />

for Enhanced Mid-range PIC<br />

microcontrollers (PIC12F1xxx/<br />

PIC16F1xxx) and demonstrates<br />

the capabilities & low power<br />

enhancements of these new PIC<br />

microcontrollers. Included with a<br />

PICkit3 for quick programming,<br />

this kit provides a platform for general purpose development and<br />

gives you the ability to develop code for any PIC12F1xxx/PIC16F1xxx<br />

microcontroller.<br />

Submit your answers to<br />

www.digikey.ca/trivia-mcu<br />

for your chance to win!<br />

Sponsored By:<br />

Official Rules: No purchase necessary to enter or claim prize. A purchase will not improve an individual’s chances of<br />

winning with such entry. Employees of Digi-Key (the “sponsor”), business partners, members of immediate families are not<br />

eligible. Void where prohibited by law or internal company policy. Valid entries contingent upon participation in the trivia<br />

contest and providing name and e-mail address. Prizes will be randomly drawn among eligible entries on or about May 7,<br />

<strong>2011</strong>. One Microchip PIC18 Starter Kit and one Microchip F1 Evaluation Platform will be awarded. Total value of all prizes<br />

will not exceed $500.00. Contest rules declare only One Microchip PIC18 Starter Kit or Microchip F1 Evaluation Platform<br />

will be awarded per winner . Winners will be contacted via e-mail. If a winner cannot be reached within 7 days of initial<br />

attempt, winner will be disqualifi ed and an alternate winner selected. Odds of winning will be determined by the number of<br />

eligible entries received. Taxes on prizes are the sole responsibility of winners. Sponsor reserves the right in its sole<br />

discretion to cancel or suspend the promotion or any portion thereof should viruses, bugs, or other causes beyond control<br />

of Sponsor corrupt the administration, security or proper play of the promotion, in which case the prizes will be awarded<br />

via a random drawing from among all eligible entries received prior to cancellation. Sponsor is not responsible or liable for<br />

late, lost, damaged or misdirected entries. Any attempts to deliberately damage any web site or undermine the legitimate<br />

operation of the promotion may be subject to prosecution of criminal and civil law. If due to a printing, production or other<br />

error, more prizes are claimed than are intended to be awarded, the intended prizes will be awarded in a random drawing<br />

from among all verifi ed and validated prize claims received. In no event will more than the stated number of prizes be<br />

awarded. Entries become the property of Sponsor and will be used in accordance with Sponsor’s privacy policy, available<br />

at: http://digikey.com/privacy. For a list of winners, mail a self-addressed, stamped envelope to be received by June 1, <strong>2011</strong><br />

to: Digi-Key Corporation, <strong>TechZone</strong> Trivia, 701 Brooks Ave South, Thief River Falls, MN 56701. If you do not want to receive<br />

any future mailings for contests of this nature, you can remove your name by calling 800-344-4539.<br />

1. Name the only 8-bit MCU provider that offers integrated USB,<br />

CAN, Ethernet, and LCD.<br />

A: Your next door neighbor C: Amazon.com<br />

B: Microchip Technology, Inc. D: Walmart<br />

2. With XLP technology, Microchip is the world-wide leader in<br />

low power. How low is eXtreme Low Power “SLEEP” on the<br />

latest PIC microcontrollers<br />

A: 5 A C: 9 nA<br />

B: 100 nA D: 10 uA<br />

3. With the HiTech C compiler, how much does it cost to start<br />

developing code on PIC microcontrollers<br />

A: About the cost of your college degree<br />

B: $5,000<br />

C: Free<br />

D: Less than the cost of “short-selling” your house<br />

4. Beyond low power “SLEEP” currents, PIC microcontrollers<br />

provide world-class low power “DYNAMIC” currents. How<br />

low can we go<br />

A:


Deeply Embedded Devices:<br />

The “Internet of Things”<br />

by Mark Wright and Rodger Richey, Microchip Technology Inc.<br />

The “Internet of Things” consists of<br />

interconnected, deeply embedded devices<br />

that need to communicate while maintaining<br />

extremely long battery life. Fortunately there<br />

are some low-power RF solutions that address<br />

both halves of the problem.<br />

The “Internet of Things” is about connecting products that create,<br />

store, and consume data via the Internet. This allows processing to<br />

provide results that can be more easily used by people. The basic<br />

technical requirements to enable this are vastly different from the<br />

current treadmill of mainstream Internet-connectivity technology.<br />

Mainstream connectivity strives to constantly increase bandwidth,<br />

range and features to counter dwindling margins and prepare for<br />

the next “killer” application. Whether this is HD media serving,<br />

on-demand TV, 4-play (voice, data, Internet and multimedia), Network<br />

Attached Storage (NAS), or the next thing you absolutely must have,<br />

mainstream connectivity requires a wider, faster-pipe mentality.<br />

Mainstream provisioning, however, is fundamentally disjointed from<br />

the requirements of the “Internet of Things.” While an Internet gamer<br />

will pay $150 to replace his 802.11b/g access point with the latest<br />

802.11a/b/g/n access point, in order to reduce game “latency” or<br />

increase their virtual “survivability,” this is not a price option for<br />

adding connectivity to a thermostat, temperature sensor, garagedoor<br />

opener, coffee maker, or lawn sprinkler. In short, the “Internet<br />

of Things” dictates a signifi cantly different adoption model than<br />

mainstream broadband support.<br />

Applications can be categorized as open, embedded, and deeply<br />

embedded. Open systems are compute-based products with<br />

purpose-loaded functions. Open systems may change their nature<br />

from one use to another. A laptop that is confi gured to be a word<br />

processor in one setting and an Internet-connected media player<br />

in another is an example of this. Due to the varying uses of open<br />

systems, the capabilities must be fl exible yet high-performance<br />

in nature, with the limitations usually driven by cost. Embedded<br />

systems are fi xed function. They may be very high- or lowperformance,<br />

with a limited energy footprint. Deeply embedded<br />

systems are single-purpose devices that are used to detect<br />

something in the environment, perform a basic level of processing<br />

and then do something with the results.<br />

Table 1: Comparison of device categories.<br />

Categories Product Examples Battery Life Data Rate Range<br />

Open PC 4 - 8 hours High Max.<br />

Embedded Access Point, iReader, AC Powered or<br />

Pocket Dictionary up to 2 years<br />

High 30 m - Max.<br />

Deeply<br />

Embedded<br />

Sprinkler Valve, Locks,<br />

Power Monitor<br />

The “Internet of Things” is primarily driven by deeply embedded<br />

devices. These devices are low- bandwidth, low-repetition<br />

data capture, and low-bandwidth data usage “appliances” that<br />

communicate with each other and provide data via user interfaces.<br />

There are embedded appliances, such as high-resolution video<br />

security cameras, video VOIP phones, and a handful of others that<br />

require high-bandwidth streaming capabilities. This article instead<br />

targets the countless products that simply require packets of data to<br />

be intermittently delivered.<br />

Figure 1: Device categories.<br />

2 years + Low - Med. 30 m<br />

Data-rate requirements and the corresponding power consumption<br />

vary signifi cantly between the different device categories. Open-type<br />

devices utilize Pentium class or similar processing, and run complex<br />

OS-based protocols for communication. Such devices require mains<br />

power, or utilize large batteries and have battery life measured in<br />

hours. Battery-operated embedded devices are products for which<br />

it is critical to reduce power consumption, design complexity, and<br />

cost through the optimization of computation occurring in the device.<br />

This is done through the use of specialized hardware, or less fl exible<br />

purpose-driven software. Deeply embedded devices build upon<br />

this optimization and often require battery operation, which creates<br />

a critical need for low power consumption. These products utilize<br />

low-power microcontrollers such as the 16-bit PIC24F family from<br />

Microchip, which features low-power sleep currents down to 20 nA<br />

and allows the use of AA or coin-cell batteries for up to 20 years of<br />

operational life.<br />

40


Examples of deeply embedded, Internet-connected devices include<br />

information displays for the home that can integrate heating and<br />

cooling control with lighting, music, and information displays (e.g.<br />

a web browser); security still cameras that provide an extra level of<br />

coverage for monitored services; appliances that allow time-of-start<br />

control from utilities for smart-energy control, to reduce consumers’<br />

electricity bills; heavy equipment with sensors that can provide<br />

remote indication when in need of pending service; and toys or<br />

multimedia handsets that could be configured for subscription<br />

services, allowing updates during off periods.<br />

The 802.11 protocol provides two basic methods of connectivity. The<br />

primary method is called infrastructure, or basic service set, and is<br />

implemented as a structured network with at least one central point<br />

that routes traffic among the devices and onto other networks. In this<br />

method, the central point is commonly called an access point, and all<br />

communications occur through the access point. The second method<br />

allows “unrelated” devices to connect temporarily. This mode is called<br />

ad hoc, or independent basic service set. Ad hoc communication occurs<br />

from device to device, but allows many devices to share the common<br />

network. A primary advantage of 802.11 over other wireless protocols<br />

is its intrinsic ability to connect devices to the Internet. However, this<br />

functionality is provided primarily through the infrastructure mode of<br />

operation. The Microchip TCP/IP stack and Microchip 802.11 radio<br />

combination supports both infrastructure and ad hoc modes of operation.<br />

Figure 2: Basic methods of connectivity.<br />

One example of a use for a deeply embedded Wi-Fi solution is for<br />

vehicle diagnostics. Considerable effort is spent designing the hardware<br />

and software for user interfaces in these types of applications. However,<br />

PDAs such as the iPod Touch or cellular phones such as the iPhone<br />

are perfectly designed for user interfaces with a rich and intuitive<br />

feature set. Most include Wi-Fi connectivity, which allows the use<br />

of infrastructure or ad hoc modes in the Microchip Wi-Fi module. As<br />

shown in Figure 3, the PDA or phone can connect to the Microchip Wi-Fi<br />

module, and the PIC24F 16-bit microcontroller runs the Microchip TCP/<br />

IP stack for ad hoc mode. The PIC24F microcontroller connects to the<br />

vehicle using any of the standard On-Board Diagnostic (OBD) interfaces,<br />

such as J1850, J1939, ISO 15765-4, etc. Vehicle status, such as RPM,<br />

MPH, and battery voltage, can be displayed in a variety of forms such<br />

as raw values, graphs, or gauges. Once disconnected, the PIC24F can<br />

connect to a central server using infrastructure mode to upload data, or<br />

download new firmware or parameters.<br />

Figure 3: Application example.<br />

Latency is not a critical factor for data transfers in most deeply<br />

embedded devices. This means the data transfer has so little<br />

latency that a user does not discern a delay from an action to the<br />

corresponding reaction. Latency is often critical for handheld remotecontrol<br />

devices, because users get frustrated and consider it a poor<br />

user experience if the time for a local reaction to a button push on the<br />

device is discernable (more than 250 ms).<br />

The 802.11 specification has a mode called “power-save poll”<br />

within the infrastructure service. It allows a device to go to sleep<br />

while maintaining a connection to the access point. A device can<br />

wake immediately and begin communication. Latency can be a little<br />

more than 100 ms for an external client to begin transferring data<br />

to a sleeping device. This is an ideal mode for remote controls using<br />

infrastructure mode, as it provides the ability to power down without<br />

a user-perceived reduction in latency. Battery life is only days with<br />

this mode if the unit is frequently used, so this usage model should<br />

be considered with a charging station. This scenario makes the usage<br />

model for such a device similar to that of a cellular phone.<br />

“Power-save poll” mode is also an efficient way to reduce power<br />

consumption in devices where latency is not an important issue, such<br />

as those that transfer data more than four times a minute. In such<br />

cases, the act of reconnecting to the network consumes more energy<br />

than keeping the device connected via power-save poll. For example,<br />

the Microchip Wi-Fi radio provides the “power-save poll” mode<br />

autonomously to the microcontroller. An added advantage of this is that<br />

the entire client system can shut down during the sleep periods. An<br />

interrupt from the radio will provide the wake indication, in case there<br />

is data waiting on the AP. Additionally, for remote-control applications,<br />

a wake-on-button-press or wake-on-motion can be provided via the<br />

microcontroller, to maintain the illusion of always being on for the user.<br />

For deeply embedded devices where latency is not critical, the best<br />

methodology for increasing battery life is to turn off the radio. The off<br />

state with leakage is the hibernate mode on the Microchip Wi-Fi radio.<br />

Once outstanding traffic is resolved via the TCP/IP stack, a single<br />

GPIO pin is used to deselect the device. This operation automatically<br />

disconnects power from the Wi-Fi radio. This mechanism allows the<br />

microcontroller and Wi-Fi radio combination to utilize about 120 nA in<br />

power-down mode. Such a combination is ideal for deeply embedded<br />

devices, because their low active power consumption stretches the<br />

system’s battery life.<br />

www.digikey.ca/microcontroller<br />

41


In all of the aforementioned deeply embedded devices, latency<br />

is not critical. Other applications where latency is not critical<br />

include security or environmental sensors, data-upload services<br />

for medical monitoring, and consumer news devices, as well as<br />

information servers.<br />

Deeply embedded devices don’t need 300 Mbps, 54 Mbps or often<br />

even 11 Mbps of throughput. A majority of deeply embedded devices<br />

use a low amount of bandwidth. They have data for transmission<br />

a few times a day, or expect to receive data possibly once a day.<br />

The amount of data they deal with is on the order of 100 bytes. By<br />

keeping external memory minimized or not using it at all, the overall<br />

system cost and power consumption remain low.<br />

A normal infrastructure connection provides about a 5-10 second<br />

reconnect period from the hibernation stage. The connect processing<br />

between the Wi-Fi radio and an access point takes about 176 ms.<br />

Connecting takes longer than this, so the majority of the time is<br />

spent in the delays associated with the access point dealing with the<br />

connection. This can be easily seen by virtue of the time it takes a<br />

standard laptop (a high-end open system) to connect to a network.<br />

This time can be reduced by using the static addressing feature of the<br />

Microchip TCP/IP stack. With such an operation, the connect time with<br />

security can be reduced to less than a second.<br />

Ad hoc connection from a power up can take less than 200 ms.<br />

For point-to-point-only remote-control devices, ad hoc operation is<br />

suitable because the achievable connection times are short. This<br />

method of operation is not often used for remotes because while<br />

it does resolve the connection-time problem, the limited use of the<br />

wireless technology for simple point–to-point only communications<br />

without LAN or internet connectivity can be better served by other<br />

wireless technologies, such as basic RF transceivers or the IEEE<br />

802.15.4 protocol.<br />

A very good application of the ad hoc mode of operation is as a<br />

default mechanism to enable easy confi guration of the device onto<br />

the network of interest. Deeply embedded products that do not<br />

have a screen/keyboard to enter data need a method for the end<br />

user to confi gure the network, as well as the security parameters<br />

of their network. In this case, the codes can be entered using a<br />

temporary network. To use a temporary network, the product must<br />

be preconfi gured to start either searching for a pre-determined<br />

infrastructure network, or by creating a pre-determined ad hoc<br />

network. In either case, another computer or Wi-Fi-enabled device<br />

(e.g. iPhone, Smartphone, etc.) connects to the product using the<br />

pre-determined network, and then confi gures the product to the<br />

fi nal desired network. Once the appropriate network information<br />

is entered, a command can be sent to the product to restart in the<br />

desired network.<br />

One advantage of 802.11 for deeply embedded devices is the<br />

ability to use pre-existing networks and the Internet. There is some<br />

concern regarding the impact to performance for other computers<br />

that use the network, when a low-bandwidth, deeply embedded<br />

device is also attached to that network. Wireless communication<br />

is a shared-bandwidth, media-access mechanism. There is a fi nite<br />

amount of bandwidth available for all to use before the airwaves get<br />

saturated with signals. The biggest impact is from clients utilizing<br />

the available bandwidth. Thus, adding a second 802.11g laptop<br />

to a network that already has an 802.11g-connected laptop on it<br />

will reduce the available bandwidth by 50 percent. The hibernate<br />

mode described earlier for power savings also serves, in this<br />

case, to minimize the effect on the network of embedded devices.<br />

Embedded devices should be confi gured to buffer their information<br />

and burst as required. Such usage will allow the devices to get on<br />

the network, transfer their data, and then get off the network. The<br />

effect of this will be maximum power savings and minimal impact<br />

on network-bandwidth capabilities.<br />

Figure 4: Example of mixed devices in a network.<br />

A critical need of deeply embedded systems is to keep the<br />

communication system easy to implement and use. While the<br />

802.11 protocol makes an ideal candidate for communication for<br />

these devices, many manufacturers are specialized in the art of<br />

their own product, and not in wireless IP communications. There<br />

is often no room in a critically costed product for more memory<br />

to run an operating system, in order to use an off-the-shelf driver<br />

that traditional 802.11 solutions offer. These drivers are created for<br />

complex operating systems, such as Windows, Windows Embedded<br />

CE, or Linux.<br />

A signifi cant benefi t of a solution like the Microchip 802.11 one is<br />

the ease of implementation to the developer. Along with the basic<br />

networking features of security, infrastructure, and ad hoc; the<br />

stack supports various services that a deeply embedded product<br />

developer would require. Some of the services supported are ICMP,<br />

HTTP, SSL, DHCP, FTP, SMTP, SNMP, TFTP, DNS, and Telnet. These<br />

are suffi cient for serving Web pages, sending and receiving data<br />

fi les, and handling e-mail services. The value to the customer is<br />

the ability to minimize code-space requirements by selecting only<br />

the services they require, accelerated time-to-market, and allowing<br />

concentration on device application and user interface, rather than<br />

on the underlying communications protocol.<br />

The “Internet of Things” is about connecting a diverse set of simple,<br />

deeply embedded devices to the tools we already use. It allows<br />

servers and other instruments that can work in the background to<br />

provide a clearer understanding of what is happening—whether<br />

the interest is in energy conservation, product maintenance, health<br />

and safety, or just information retrieval. The Microchip 802.11<br />

solution has been designed with the mindset for deeply embedded<br />

devices. This solution takes into consideration the speed, bandwidth,<br />

and latency needs of embedded devices—these being much<br />

42


less than what most people demand for their day-to-day Internet<br />

connectivity experience. This makes the solution much lower in<br />

power and easier to use than standard IP-connection alternatives.<br />

The solution is also compatible with the cost constraints of<br />

deeply embedded devices. These characteristics allow the system<br />

developer to concentrate on application development rather than on<br />

networking knowledge.<br />

While it is said that the “Internet of Things” will progress to a<br />

billion new connected things by <strong>2011</strong>, the majority of these will<br />

be in embedded and deeply embedded devices. The unique<br />

characteristic of IP connectivity is that having devices connected<br />

and providing improved effi ciency is not the only benefi t. The<br />

real return is the progression of benefi ts that will result from the<br />

interconnecting of devices to a wider and automated information<br />

database. This can include better performance through longer<br />

operation within optimal ranges, new revenue streams that will<br />

give users simplicity in dealing with things that otherwise go into<br />

disrepair, and also increased sales pull-through via product and<br />

information co-marketing.<br />

Intro to PIC24FJDA Family<br />

Microchip Technology<br />

The PIC24FJDA family from Microchip features graphic<br />

acceleration and direct interface to STN, TFT, and OLED<br />

displays. The series comes with 64-pin QFN, TQFN, and for<br />

the fi rst time BGA packages.<br />

The product training<br />

module for this<br />

series provides<br />

in-depth lists of<br />

the products’ many<br />

features, explains the<br />

properties of Power<br />

Consumption, and<br />

a cost comparison<br />

chart for budget planning.<br />

This module can be experienced with or without audio in<br />

approximately 15 minutes<br />

and is 24 pages in length.<br />

www.digikey.ca/ptm<br />

PIC24F04KA201 Family<br />

As more electronic applications require low power or battery<br />

power, energy conservation becomes paramount. Products with<br />

Microchip’s nanoWatt XLP Technology offer the industry’s lowest<br />

currents for Run and Sleep modes. The PIC24F04KA201 family is<br />

ideal for low cost, low pin-count applications (14-20 pins) which<br />

require up to 4 KB Flash that also need 16-bit performance (16<br />

MIPS). This family includes a range of peripherals including timers,<br />

UART, SPI, I 2 C, ADC, comparators and CTMU for precise time<br />

measurement or touch sensing. With full analog and self write<br />

capability down to 1.8 V, the PIC24 “KA” family will extend the<br />

battery life in your next design.<br />

Use the free Microchip XLP Battery Life Estimator to select the<br />

target MCU, battery type, and energy profi le to get an estimate of<br />

battery life for your application. It’s easy to get started with the<br />

XLP MCUs, using the XLP 16-bit Development Board (DM240311),<br />

which includes current measurement terminals and fl exible power<br />

sources (AAA, coin cells or energy harvesting modules).<br />

Example applications for the new PIC24F04KA microcontrollers include:<br />

• Medical (portable and home medical devices, oxygen fl ow<br />

meters, lifestyle/fi tness monitors)<br />

• Industrial (energy harvesting/scavenging, water/gas/heat<br />

meters, portable gas sensors, remote sensor networks, asset<br />

tracking, sealed/harsh environment sensors)<br />

• Consumer (security-system dongles, sealed disposable<br />

electronics, portable electronics, smart cards)<br />

www.digikey.ca/microchip-mcu<br />

www.digikey.ca/microcontroller<br />

43


Peripheral Reflex System<br />

Avoids MCU Overload<br />

contributed by Energy Micro<br />

Normally, MCUs spend much of their time<br />

passing information between peripherals. That<br />

doesn’t have to be the case.<br />

The Peripheral Refl ex System (PRS) is a network which lets the<br />

different peripheral modules communicate directly with each other<br />

without involving the CPU. Peripheral modules which send out Refl ex<br />

signals are called producers. The PRS routes these refl ex signals to<br />

consumer peripherals which apply actions depending on the Refl ex<br />

signals received. The format for the Refl ex signals is not given, but<br />

edge triggers and other functionality can be applied by the PRS.<br />

Overview<br />

An overview of one channel and how four different peripherals can<br />

be connected using PRS is given in Figure 1. The PRS contains eight<br />

interconnect channels, and each of these can select between all of<br />

the output Refl ex signals offered by the producers. The consumers<br />

can then choose which PRS channel to listen to and perform actions<br />

based on the Refl ex signals routed through that channel. The Refl ex<br />

signals can be both pulse signals and level signals. Synchronous PRS<br />

pulses are one HFPERCLK cycle long, and can either be sent out by<br />

a producer (e.g. ADC conversion complete) or be generated from the<br />

edge detector in the PRS channel. Level signals can have an arbitrary<br />

waveform, but will be synchronized with the HFPERCLK.<br />

Producer<br />

Side<br />

Channel 0<br />

Signals from<br />

producer<br />

peripherals<br />

TIMER0<br />

Overflow Pulse<br />

ACMP<br />

Output Level<br />

.<br />

.<br />

.<br />

.<br />

.<br />

PRS<br />

x8<br />

SIGSEL[2:0]<br />

SOURCESEL[5:0]<br />

EDSEL[1:0]<br />

SWPULSE[0]<br />

SWLEVEL[0]<br />

ADC0<br />

Start single conv.<br />

Reg<br />

APB bus<br />

Signals to<br />

consumer<br />

perpherals<br />

TIME1<br />

CC1 Input<br />

Consumer<br />

Side<br />

Figure 1 shows four peripherals connected to two PRS channels.<br />

On one channel is TIMER0 and ADC0 and the ACMP and TIMER1 are<br />

connected to a second channel. An overfl ow from TIMER0 can start an<br />

ADC single conversion and an ACMP output can be used as input for a<br />

Compare/Capture channel on TIMER1.<br />

General operation<br />

Channel functions<br />

Different functions can be applied to a Refl ex signal within the<br />

PRS. Each channel includes an edge detector to enable generation<br />

of pulse signals from level signals. It is also possible to generate<br />

output Refl ex signals by software writing to PRS_SWPULSE and<br />

PRS_SWLEVEL registers. PRS_SWLEVEL is a programmable level<br />

for each channel and holds the value it is programmed to. The<br />

PRS_SWPULSE will give out a one-cycle high pulse if it is written to<br />

1, otherwise a 0 is asserted. The SWLEVEL and SWPULSE signals<br />

are then XOR’ed with the selected input from the producers to form<br />

the output signal sent to the consumers listening to the channel.<br />

This is illustrated in Figure 1.<br />

The efm32lib function void PRS_<br />

SourceSignalSet(unsigned int ch, uint32_t<br />

source, uint32_t signal, PRS_Edge_TypeDef<br />

edge) can be used to easily confi gure the PRS channels. By<br />

specifying the PRS channel producing peripheral signal from<br />

the peripheral and the edge for pulse generation, the function<br />

confi gures the PRS accordingly.<br />

Producers<br />

Each PRS channel can choose between signals from several<br />

producers, which is configured in SOURCESEL in PRS_CHx_CTRL.<br />

Each of these producers outputs one or more signals which can<br />

be selected by setting the SIGSEL field in PRS_CHx_CTRL. Setting<br />

the SOURCESEL bits to 0 (Off) leads to a constant 0 output from<br />

the input mux. An overview of the available producers is given in<br />

Table 1.<br />

Consumers<br />

Consumer peripherals (Table 2) can be set to listen to a PRS channel<br />

and perform an action based on the signal received on that channel.<br />

Most consumers expect pulse input, while some can handle level<br />

inputs as well.<br />

Figure 1: PRS overview.<br />

44


Table 1: Reflex producers.<br />

Module Reflex Output Output Format<br />

ACMP Comparator Output Level<br />

ADC Single Conversion Done Pulse<br />

Scan Conversion Done<br />

Pulse<br />

DAC Channel 0 Conversion Done Pulse<br />

Channel 0 Conversion Done Pulse<br />

GPIO Pin 0 Input Level<br />

Pin 1 Input<br />

Level<br />

Pin 2 Input<br />

Level<br />

Pin 3 Input<br />

Level<br />

Pin 4 Input<br />

Level<br />

Pin 5 Input<br />

Level<br />

Pin 6 Input<br />

Level<br />

Pin 7 Input<br />

Level<br />

Pin 8 Input<br />

Level<br />

Pin 9 Input<br />

Level<br />

Pin 10 Input<br />

Level<br />

Pin 11 Input<br />

Level<br />

Pin 12 Input<br />

Level<br />

Pin 13 Input<br />

Level<br />

Pin 14 Input<br />

Level<br />

Pin 15 Input<br />

Level<br />

RTC Overflow Pulse<br />

Compare Match 0<br />

Pulse<br />

Compare Match 1<br />

Pulse<br />

TIMER Underflow Pulse<br />

Overflow<br />

Pulse<br />

CC0 Output<br />

Level<br />

CC1 Ouput<br />

Level<br />

CC2 Output<br />

Level<br />

UART TX Complete Pulse<br />

RX Data Received<br />

Pulse<br />

USART TX Complete Pulse<br />

RX Data Received<br />

Pulse<br />

IrDA Decoder Output<br />

Level<br />

VCMP Comparator Output Level<br />

Table 2: Reflex consumers.<br />

Module Reflex Input Input Format<br />

ADC Single Mode Trigger Pulse<br />

Scan Mode Trigger<br />

Pulse<br />

DAC Channel 0 Trigger Pulse<br />

Channel 1 Trigger<br />

Pulse<br />

TIMER CC0 Input Pulse/Level<br />

CC1 Input<br />

Pulse/Level<br />

CC2 Input<br />

Pulse/Level<br />

DTI Fault Source 0 (TIMER0 only) Pulse<br />

DTI Fault Source 1 (TIMER0 only) Pulse<br />

DTI Input (TIMER0 only)<br />

Pulse/Level<br />

UART TX/RX Enable Pulse<br />

USART TX/RX Enable Pulse<br />

IrDA Encoder Input (USART0 only) Level<br />

Software examples<br />

This section describes four software examples that explore possible<br />

interactions between peripherals using the PRS:<br />

• TIMER triggered ADC conversion<br />

• Pulse Width Measurement with the ACMP and TIMER<br />

• GPIO triggered UART transmission<br />

• Software triggered DAC conversion<br />

TIMER triggered ADC conversion<br />

Figure 2 shows how to set up ADC0 to start a single conversion every<br />

time that TIMER0 overflows. TIMER0 sends a one HFPERCLK cycle<br />

high pulse sent from TIMER0 to the ADC0 through the PRS on each<br />

overflow, and the ADC does a single conversion which is displayed<br />

on the LCD of the STK/DK development boards. The ADC consumes<br />

pulse signals, which are the same signals produced by the TIMER. In<br />

this case there is no edge detection needed, so the PRS leaves the<br />

incoming signal unchanged.<br />

Producer<br />

Side<br />

Channel 5<br />

Signals from<br />

producer<br />

peripherals<br />

TIMER0<br />

Overflow Pulse<br />

1 HFPERCLK Pulse<br />

SIGSEL[2:0]<br />

SOURCESEL[5:0]<br />

EDSEL[1:0]<br />

SWPULSE[5]<br />

SWLEVEL[5]<br />

ADC0<br />

Start single conv.<br />

APB bus<br />

Signals to<br />

consumer<br />

perpherals<br />

Figure 2: TIMER0 overflow starting ADC0 single conversions using the PRS.<br />

PRS<br />

Consumer<br />

Side<br />

The ADC is configured with 8-bit resolution and Vdd as both<br />

reference and input. When the ADC finishes the conversion it<br />

generates a single conversion complete interrupt. The CPU will then<br />

fetch the result and display it on the LCD. The displayed result is a<br />

direct reading from the ADC0_SINGLEDATA register which is always<br />

255, given that the input is the same as the reference. The DMA can<br />

also be used to fetch the conversion result and that is covered by<br />

the AN0021 Analog to Digital Converter.<br />

The software project prs_timer_adc implements this example<br />

and can be used on both STK and DK development boards.<br />

Pulse width measurement with ACMP and TIMER<br />

Figure 3 illustrates how to measure the pulse width or period of an<br />

arbitrary waveform. The ACMP is used to send a level signal through<br />

the PRS. TIMER0 consumes both pulse and level signals so the PRS<br />

leaves the incoming signal unchanged. On TIMER0 the PRS signal is<br />

used as input for CC0 channel. TIMER0 starts counting on a positive<br />

edge and captures the counter value on a negative edge.<br />

Reg<br />

1 HFPERCLK Pulse<br />

www.digikey.ca/microcontroller<br />

45


Channel 5<br />

SIGSEL[2:0]<br />

SOURCESEL[5:0]<br />

EDSEL[1:0]<br />

APB bus<br />

must be used to generate a pulse signal on a GPIO positive edge<br />

transition. The clock pulse enables the USART TX and transmits the data<br />

that was placed in the TX buffer. For the GPIO to generate PRS signals,<br />

the PRS Sense must be enabled in the GPIO_INSENSE register.<br />

Signals from<br />

producer<br />

peripherals<br />

SWPULSE[5]<br />

SWLEVEL[5]<br />

Reg<br />

Signals to<br />

consumer<br />

perpherals<br />

The software project prs_gpio_uart implements this example<br />

and is intended for the DK only. To enable the USART TX, pin PD0 must<br />

be connected to VMCU to generate a positive edge. The EFM32 will then<br />

send the character ‘X’ through SERIAL A with a 57600 baud rate, no<br />

parity and one stop bit.<br />

Producer<br />

Side<br />

ACMP<br />

Output Level<br />

PRS<br />

TIMER0<br />

Reload&Start + Capture&Stop<br />

Consumer<br />

Side<br />

Software generated PRS pulse triggers DAC conversion<br />

Figure 5 shows how to generate a PRS pulse by software. The PRS<br />

pulse will trigger a DAC conversion which outputs a 0.5 V signal on<br />

pin PB11. It is possible to generate both pulse and level signals by<br />

software. In this case a pulse signal is generated because it is the type<br />

of signal consumed by the DAC. DAC conversions can also be started<br />

by software in the DAC itself. This example only shows how this can be<br />

done through the PRS as well.<br />

Level<br />

Figure 3: ACMP level output used as PRS signal for TIMER0 CC0 channel input.<br />

Level<br />

Channel 5<br />

SIGSEL[2:0]<br />

Figure 3 also shows the level output from the ACMP sent through the PRS<br />

to the TIMER which measures the pulse width using the capture feature.<br />

The software project prs_pulse_width implements this<br />

example and can be used on both STK and DK. To trigger the pulse<br />

width measurement, pin PC4 (P4.7 on the DK protoboard) must be<br />

connected to VMCU to generate a high level that will trigger the ACMP<br />

and start the TIMER. When the connection is released, the output of<br />

the ACMP will be low again and the TIMER captures the counter value<br />

and displays it on the LCD.<br />

GPIO triggered USART transmission<br />

Figure 4 illustrates how to use an external signal coming through the GPIO<br />

to enable the USART transmitter. It shows a positive edge from a GPIO<br />

pin sent on the producer side through the PRS edge detector to create<br />

a one HFPERCLK cycle pulse on the consumer side. The GPIO produces<br />

level signals which are not consumed by the UART so the edge detector<br />

Producer<br />

Side<br />

Channel 5<br />

Signals from<br />

producer<br />

peripherals<br />

GPIO<br />

Output Level<br />

Positive Edge<br />

PRS<br />

SIGSEL[2:0]<br />

SOURCESEL[5:0]<br />

EDSEL[1:0]<br />

SWPULSE[5]<br />

SWLEVEL[5]<br />

UART<br />

Enable TX<br />

Figure 4: USART TX enabled by GPIO signal using the PRS.<br />

Reg<br />

1 HFPERCLK Pulse<br />

APB bus<br />

Signals to<br />

consumer<br />

perpherals<br />

Consumer<br />

Side<br />

Producer<br />

Side<br />

Signals from<br />

producer<br />

peripherals<br />

Figure 5: Software triggered PRS signal.<br />

SOURCESEL[5:0]<br />

EDSEL[1:0]<br />

SWPULSE[5]<br />

SWLEVEL[5]<br />

APB bus<br />

Figure 5 shows a one HFPERCLK cycle pulse triggered from software.<br />

Pulse and level signals can be generated by software by writing directly<br />

to the PRS_SWPULSE and PRS_SWLEVEL registers respectively. They<br />

can also be generated using functions from the efm32lib:<br />

• void PRS_PulseTrigger(uint32_t channels)<br />

generates pulse signals<br />

• void PRS_LevelSet(uint32_t level,<br />

uint32_t mask) generates level signals<br />

PRS<br />

DAC0<br />

Start conv.<br />

Signals to<br />

consumer<br />

perpherals<br />

Consumer<br />

Side<br />

The software project prs_soft_dac implements this example<br />

and can be used on both STK and DK.<br />

Monitoring of PRS signals<br />

The PRS channels can be monitored using peripherals that consume<br />

PRS signals. One example is using a TIMER to make a capture when<br />

there is activity on the PRS channel it is connected to. The software<br />

project main_prs_channel_scan exemplifi es how this can<br />

be accomplished and can be used on both STK and DK.<br />

Reg<br />

1 HFPERCLK Pulse<br />

46


The function PRS_ScanChannel(TIMER_TypeDef<br />

*timer, TIMER_PRSSEL_TypeDef prsCh,<br />

TIMER_Edge_TypeDef edgeType) in the main_<br />

prs_channel_scan project can be used to monitor activity on a<br />

specifi c PRS channel. It sets the CC0 channel on the chosen TIMER to<br />

capture a selected signal edge. The project can be used on both STK<br />

and DK and the parameters are as follows:<br />

• timer: pointer to the TIMER peripheral register c\block<br />

• prsCh: PRS channel to be monitored<br />

• edgeType: signal edge to be monitored/captured<br />

This function will hang on a while loop waiting for activity in the PRS<br />

channel. When such activity occurs, it writes PRS and the channel<br />

number on the LCD. To generate activity on this line, the user must<br />

connect PC4 to VMCU to generate a rising edge transition on the PRS<br />

channel using the ACMP.<br />

Another option is to have a capture interrupt instead of polling. That<br />

way the program will not hang and the processor will be available to<br />

execute other tasks. When a capture is triggered, the user knows that<br />

there was activity on the selected PRS channel.<br />

Innovations in Connectivity:<br />

a look inside Digi-Key’s state-of-the-art Weather Center<br />

iDigi Server<br />

Ethernet, WiFi, Cellular<br />

Computer<br />

HTML,<br />

Gadgets, Widgets<br />

Node<br />

(Wired/Wireless)<br />

Drivers<br />

Gateway<br />

(Cellular, WiFi,<br />

Ethernet, Satellite)<br />

Drivers<br />

Internet<br />

(Cloud)<br />

Cell Phone<br />

Digi-Key Server<br />

WiFi, Cellular<br />

Android, iPhone,<br />

Blackberry Apps<br />

Weather Center Structure<br />

12VDC<br />

Power Rail<br />

In a wireless world, devices like the Digi-Key<br />

Weather Center utilize the best in electronic<br />

components to test conditions in an environment<br />

where temperatures range from sizzling to<br />

subzero. Above is a diagram depicting the process<br />

by which Digi-Key’s Weather Center conveys the<br />

data collected to computers and mobile devices.<br />

This connectivity is achieved by Digi-Key’s<br />

custom-made weather tracking system—<br />

composed of the best in wireless, sensor,<br />

microcontroller, and lighting technology.<br />

Outer Design<br />

The Digi-Key Weather Center was constructed in<br />

a simple “T” shaped design. Measuring three feet<br />

across, the top beam is made of three-inch “C”<br />

channel. This provides a place for sensor modules,<br />

an anemometer, and any future additions.<br />

The trunk of Digi-Key’s Weather Center is<br />

approximately seven feet tall and composed of<br />

three-inch square tubing. Mounting brackets for<br />

solar panels and the electronic box are attached.<br />

The Weather Center is supported by a square<br />

plate, measuring two feet across.<br />

Inside the Weather Center<br />

The heart of the Weather Center, the main box<br />

located in the middle of the Weather Center’s<br />

trunk, is from BUD’s NBA series, Digi-Key part<br />

number 377-1139-ND. This box is rated at IP65<br />

of IEC 529 and NEMA 1, 2, 4 and 4x specifi cations<br />

with temperature ranges from -40°C to over 70°C.<br />

While the Digi-Key Weather Center has seen<br />

nearly 100°F of heat in the summer and has been<br />

exposed to -38°F temperatures in the winter, the<br />

center has remained resilient.<br />

To provide venting for the center’s box, Bud’s<br />

NBX-10910-ND and the NBX-10911-ND moisture<br />

vents were installed. Although the center has<br />

experienced harsh weather conditions, no moisture<br />

or debris has been detected within the box.<br />

The top beam is made of “C” channel, which provides a place<br />

for sensor modules, an anemometer, and any future additions.<br />

To interface the box to the sensors, Switchcraft’s<br />

SC1390-ND Jack and the SC1381-ND Plug were<br />

utilized. These connectors are rated at IP68 when<br />

properly mated.<br />

On the inside of the box, Injectorall Electrics’ FR4<br />

unclad board material (PC8-UNCLAD-ND) was<br />

installed to create a proper back panel. On the panel<br />

the primary circuit board and two power distribution<br />

strips by Molex (WM5737-ND) were applied.<br />

This inside look at the mechanics behind Digi-<br />

Key’s Weather Center is the second in a series of<br />

articles that will explore the development of the<br />

Weather Center’s technology and the innovations<br />

of connectivity. Additional articles will appear in<br />

upcoming issues of <strong>TechZone</strong> magazines. For<br />

more information about the Digi-Key Weather<br />

Center, visit connectivity.digikey.com.<br />

An update was made in November 2010 to include three solar<br />

panels in order to collect as much solar energy as possible.<br />

www.digikey.ca/microcontroller<br />

47


CAN Primer: Creating<br />

Your Own Network<br />

by Bob Boys, ARM<br />

CAN is a flexible network that is easy to<br />

implement. If you are considering networking<br />

topologies for your next embedded design,<br />

this article will set you on the right path.<br />

CAN is extensively used in automobiles and trucks and can be found<br />

in multiple applications. There are many “application” layers available<br />

for CAN, such as ISO 15765 (cars), J1939 (trucks), and CANopen<br />

(factory automation), but it is very easy to develop your own protocol<br />

to fi t and simplify your needs. Modern CAN transceivers provide a<br />

stable and reliable CAN physical environment without the need for<br />

expensive coaxial cables. Most of the mystery of CAN has dissipated<br />

over the years. There is plenty of example CAN software available to<br />

help you quickly develop your own network.<br />

A CAN controller is a sophisticated device. Nearly all the features<br />

of the CAN protocol described below are automatically handled by<br />

the controller with almost no intervention by the host processor. All<br />

you need to do is confi gure the controller by writing to its registers,<br />

write data to the controller, and the controller then does all the<br />

housekeeping work to get your message on the bus.<br />

The controller will also read any frames found on the bus and hold<br />

them in a small FIFO memory. It will notify the host processor that this<br />

data is available, which is then read from the controller. The controller<br />

also contains a hardware fi lter mechanism that can be programmed<br />

to ignore the CAN frames you do not want passed to the processor.<br />

For the purposes of this article; we will assume a CAN network<br />

consists of the physical layer (the voltages and the wires) and a frame<br />

consisting of an ID and a varying number of data bytes. CAN has the<br />

following general attributes:<br />

1. 11- or 29-bit ID and from zero to eight data bytes. These can be<br />

dynamically changed “on the fl y.”<br />

2. Peer-to-Peer network. Every node can see all messages from all<br />

other nodes. A node cannot read its own messages.<br />

3. Nodes are easy to add. Attach one to the network with two wires<br />

plus a ground.<br />

4. Higher priority messages are sent fi rst depending on the value of<br />

the ID. A lower ID has the highest priority.<br />

5. Automatic retransmission of defective frames. A node will “busoff”<br />

if it causes too many errors.<br />

6. Speeds from approximately 10 Kbps to 1 Mbps. All nodes must<br />

operate at the same frequency.<br />

7. The twisted differential pair provides excellent noise immunity<br />

and some decent bus fault protection.<br />

8. The CAN system will work with the ground connection at<br />

different DC levels or no ground at all.<br />

The CAN system layout<br />

A CAN network consists of at least two nodes connected together<br />

with a pair of twisted wires, as shown in Figure 1. A ground wire can<br />

be included with the twisted pair or separately as part of the chassis.<br />

One twist per inch (or more) will suffi ce, and the integrity of the<br />

ground is not necessary for normal operation. As in any differential<br />

systems, the voltage levels between the wire pair are important, and<br />

not their values to ground. CAN is completely described in ISO 11898.<br />

The maximum length of the network is dependent on the frequency,<br />

number of nodes and propagation speed of the wire. It is relatively<br />

easy to have a 20 node (or more), 500 Kbps system running 30 or 40<br />

feet (or more). The drops should be less than three feet and randomly<br />

spaced to reduce standing waves. These issues all become more<br />

important at higher bus speeds.<br />

Figure 1: A CAN network.<br />

Since the twisted pair is a transmission line, 120 ohm termination<br />

resistors are needed at both ends of the backbone. Do not put any<br />

resistors at the nodes. Your total resistance value as measured<br />

between the two twisted wires will be 60 ohms. CAN is a broadcast<br />

system. Any node can “broadcast” a message using a CAN frame<br />

on a bus that is in idle mode. Every node will see this message. A<br />

“message” can be considered the same as a CAN frame until you<br />

need to use more than one frame to send a long message. It is up to<br />

the individual node if it must react to a CAN frame or just ignore it.<br />

48


Figure 2: Schematic diagram from the<br />

Keil MCBSTM32E evaluation board.<br />

A node schematic<br />

Figure 2 shows the schematic diagram from the Keil MCBSTM32E<br />

evaluation board. IC1 is a Texas Instruments CAN transceiver that<br />

performs the conversion between the single-ended CAN controller<br />

CAN Tx and CAN Rx signals to the bidirectional differential pair of<br />

the CAN bus called CANH and CANL (High and Low). This schematic<br />

is complete.<br />

The STM32 CAN I/O is TTL, CMOS and 5 V tolerant, making it<br />

exceptionally easy to design the interface. This transceiver IC1<br />

connects to the STM32 microprocessor IC2, which contains an<br />

integral CAN controller via two pins: D (Driver input) and R (Receiver<br />

output). The corresponding nomenclature on the STM32 is CAN Rx<br />

and CAN Tx. CAN Tx connects to D. CAN Rx connects to R. Some<br />

processors have multiple CAN controllers. These are usually used<br />

in routers, gateways or to create more receiver FIFO memory for<br />

intentionally slowed down CPUs (for EMI reasons). For general use, a<br />

node normally needs only one controller. If it had at least two, it could<br />

talk to itself.<br />

RS on IC1 (slope control) is used to adjust the rise and fall times of<br />

the output edges to limit EMI from the twisted pair. Note R4 is a 120<br />

ohm termination resistor. This evaluation board is meant to be used<br />

with one other board as a small test network. If this board is used as<br />

a node, and is not at one of the ends, this resistor should be removed<br />

and external resistors used. P17 corresponds to a generally accepted<br />

standard for CAN on DB9 connectors. P17 Pin 7 is the CAN Hi bus line<br />

and pin 6 is CAN Lo. If CAN Hi and CAN Lo are reversed, the network<br />

will not operate properly. It might not work at all.<br />

There are three physical layers used in CAN: Hi-Speed, Fault Tolerant<br />

and Single Wire. Hi-Speed is the most common and is the one we will<br />

use in this article. Fault Tolerant offers more robustness as its name<br />

implies and is used more often in European autos. Single Wire is used<br />

by General Motors as a low-speed body network along with Hi-Speed<br />

main network.<br />

Hi-Speed in cars has a speed of 500 Kbps, trucks are 250 kbps.<br />

CANopen runs up to 1 Mbps. Fault Tolerant is usually 125 kbps, and<br />

GM Single Wire is normally 33.33 kbps. One Mbps in a large system is<br />

difficult to handle. 500 kbps is easier.<br />

To change from one to the other requires only the transceiver chip<br />

to be exchanged and probably changing the speed. These three<br />

layers cannot be physically connected to each other as the voltage<br />

levels are different. Use a router or gateway to join different CAN<br />

networks together. Any CAN controller will properly service all three<br />

layers of CAN.<br />

The Hi-Speed CAN physical layer is a pair of twisted wires with a<br />

120 ohm termination resistor at each end and twisted wire drops to the<br />

individual CAN nodes. A node can be directly connected to the bus.<br />

CAN Hi voltage, with respect to ground, changes between 2.5 to 4<br />

volts nominal. CAN Lo changes from 2.5 to 1 volt. Therefore, the<br />

difference between the two is either 0 volts (is logical “1”) or 3 volts<br />

(logical “0”). 0 is known as the “dominant” state and 3 volts is the<br />

“recessive” state.<br />

These two signals, CAN Hi and CAN Lo, are 180 degrees out of phase.<br />

Bus idle is when the voltage difference is zero.<br />

The CAN frame<br />

The CAN frame has many fields but can be simplified to a<br />

Programming Model as shown in Figure 3. These fields must be<br />

written by software or read from the CAN controller registers. The CAN<br />

configuration registers are not included.<br />

Figure 3: CAN Frame Programming Model.<br />

• IDE: Identifier Extension: 1-bit - specifies if the ID field is 11 or<br />

29 bits.<br />

If IDE = 0, then the ID is 11 bits.<br />

If IDE = 1, then the ID is 29 bits.<br />

• DLC: Data Length Code: 4 bits - specifies number of data bytes<br />

in frame from 0 through 8.<br />

• ID: Identifier: 11 or 29 bits as set by IDE. This part of the CAN<br />

frame sets the priority.<br />

• Data Bytes: 0 through 8 bytes. A CAN frame with only an ID field<br />

and no data bytes is valid and useful.<br />

www.digikey.ca/microcontroller<br />

49


ID: Identifier: 11 or 29 bits<br />

The Identifi er can be used for any purpose. It is often used as a node<br />

address or to identify requests and responses. CAN does not specify<br />

what the ID should be.11-bit is sometimes called Standard CAN and<br />

29-bit is called Extended CAN.<br />

1. If two or more CAN messages are put on the bus at the same<br />

time; the one with the highest priority (the lowest value) ID will<br />

immediately get through. The others will be delayed and will be<br />

resent as soon as possible.<br />

2. An ID of 0 has the highest priority and will always get through.<br />

An 11-bit ID has priority over any 29-bit ID.<br />

3. The ID size can be changed at any time for a mix of 11- and<br />

29-bit IDs. The controller can easily sort this out.<br />

4. Messages tend to start transmitting at the same time. It is not<br />

permissible for a CAN node to start transmitting if another is<br />

already transmitting. This will cause a bus error.<br />

5. Note that a CAN controller can be confi gured to pass only certain<br />

messages to its host processor. Choose ID values carefully to<br />

take advantage of this, if needed. This can take a large work load<br />

off of a node’s processor.<br />

6. Use the ID for data, node addressing, commands and request/<br />

response sequences. Commercial protocols use these in<br />

practice. Choose any method or create your own to best suit<br />

your purpose.<br />

7. Make sure two nodes will never send the same ID value at the<br />

same time. It is illegal but possible to do this. If two messages<br />

sent at the same time are identical, they will be seen as one. If<br />

the data bytes are different, this will result in a bus error and the<br />

frames will be resent continuously, creating havoc on the bus<br />

until bus-off occurs.<br />

Data bytes<br />

Select from zero to eight data bytes using the 4-bit DLC fi eld.<br />

1. Any number of data bytes can be mixed on the CAN bus. The<br />

controller can easily sort this out.<br />

2. By always using only one number of data bytes,<br />

software will be much simpler to write and maintain.<br />

3. The data bytes can contain anything. It will not be prioritized like<br />

the ID. CAN does not specify data contents.<br />

4. Commercial protocols such as J1939 use these for data as well<br />

as control bits for multi-frame transmission schemes.<br />

Remote frames<br />

Though not used often, a remote frame is a quick method of getting a<br />

response from another node(s). It is a request for data. The requesting<br />

node sends out a shortened CAN frame with only a user specifi ed ID<br />

number and the number of data bytes it expects to receive (the DLC<br />

is set). No data fi eld is sent. The responding node(s) sees this ID and<br />

DLC, recognizes that it has the desired information and sends back<br />

a standard CAN frame with the same ID, DLC and with its data bytes<br />

attached. All of this (except that the response node recognizes the ID<br />

and DLC) is implemented in the CAN controller hardware. Everything<br />

else must be confi gured by the user software.<br />

Bus loading<br />

Many CAN networks work on a bus loading from 15 to 35 percent<br />

and this is increasing. A higher bus loading can cause lower priority<br />

messages to be delayed, but these messages will still get through in<br />

a timely fashion. It is quite diffi cult to achieve 100 percent bus loading<br />

although one can come quite close. Overall system performance does<br />

not drop greatly at high bus loading.<br />

It is possible to get very high bus loads for a very short period of time<br />

in any CAN network. CAN does not automatically space out messages.<br />

It is possible to get a series of back-to-back messages that will<br />

equal nearly 100 percent bus loading. One solution is to select only<br />

those messages needed by a node by programming its acceptance<br />

fi lter. Another is to have your software space out the messages. This<br />

problem is diffi cult to diagnose.<br />

Bus speed<br />

Bus speed in a system is a balancing act between things such as<br />

propagation delays (from bus length) and EMI emissions versus<br />

necessary data throughput. Run the network as fast as possible for<br />

stable operation and with enough throughput. Do not run it faster than<br />

necessary, but make some room for later expansion.<br />

If the network is not stable, make sure there are two good termination<br />

resistors at each end of the network. Try slowing the CAN speed<br />

down to see if this helps. Resistors can be ordinary 120 ohm 1/2 watt<br />

carbon type. This is not critical.<br />

TIP: How to determine the frequency of a CAN signal: (This is the best<br />

and sometimes only way to determine this.)<br />

1. Connect an oscilloscope hot lead to CAN Hi and its ground to CAN<br />

Lo. The scope ground must be isolated from the CAN ground. You<br />

can go from ground to one of the CAN leads, but the signals will<br />

be lower and noisier.<br />

2. Display a trace. A storage scope may be needed to see just one<br />

trace due to the non-repetitive nature of CAN.<br />

3. Pick the smallest width signal pulse and measure its time period<br />

in seconds as accurately as possible.<br />

4. Invert this value (divide into 1)to obtain the CAN speed in bits per<br />

second.<br />

Bus errors<br />

Recall that all the nodes (including the transmitting node) check each<br />

CAN frame for errors. If an error is detected, the following occurs:<br />

1. Any or all of the nodes will signify this fact by driving the bus to<br />

logical 0 (dominant state) for at least six CAN bits.<br />

2. This violates the Bit Stuffi ng rule (never greater than 5 bits the<br />

same polarity), so every node sees this as an error.<br />

3. This so called “Error Frame” signals to all nodes a serious error<br />

has occurred.<br />

4. The transmitting bus abandons the current frame and adds four<br />

to its 8-bit TEC (Transmit Error counter) register.<br />

5. If this TEC equals 0xFF, the transmitting node goes BUS OFF and<br />

takes itself off the bus (it is zero at RESET).<br />

50


6. If not, it attempts to retransmit its message. It will still have to go<br />

through the priority process with other messages.<br />

7. All other nodes also abandon reading the current frame, and<br />

adds four to each REC (Receive Error Counter) register.<br />

8. Any nodes that have messages queued up for transmission will<br />

transmit now. All others start listening to the bus.<br />

9. Hopefully, this time the message(s) will be broadcast and<br />

received error free. Each time a frame is transmitted and/or<br />

received successfully, the corresponding TEC and REC registers<br />

are decremented (usually by only one).<br />

TIP: Error counters These are two 8-bit registers in every CAN<br />

controller and you can read these with your software. This is a good<br />

idea because it gives some indication of general bus health and<br />

stability. In a good CAN network, TEC and REC will equal zero. If it<br />

starts having higher values, something has happened to your network.<br />

The usual suspect is bad hardware. The problem is usually in either<br />

the wires or the transceiver chip.<br />

Don’t forget that if something happens to the integrity of the twisted<br />

pair, such as CAN Lo disconnected; it might still work but with greatly<br />

reduced noise immunity (that is what differential signals do best). If<br />

the network is in a very noisy environment, there might be a lot more<br />

transient bus errors. This is very tricky to debug without knowledge of<br />

the REC and TEC register contents. Put this in the software and report<br />

it to the diagnostic routines.<br />

In a general sense, TEC represents a given node’s errors and REC<br />

indicates the other nodes’ errors.<br />

Bus off: As mentioned, if a transmitting node detects it has put too<br />

many bad frames on the bus, it will disconnect itself. It will assume<br />

that there is something very wrong with itself. To get back on the bus<br />

depends on how the controller is configured. It can take a controller<br />

RESET or a certain number of good frames received or what is<br />

configured to get back on.<br />

TIP: How can you create a Bus Error for testing<br />

Have a node send a message at the wrong frequency. When this<br />

frame tries to get on the bus, this is certain to create a bus error<br />

condition. Some CAN controllers can send a one-shot frame.<br />

BUS faults<br />

This is different from a bus error. We normally think of a bus fault as<br />

something that has happened to the “wires” or the output transistors<br />

of the transceiver chip. Not all bus faults will result in a bus error. A bus<br />

error can be thought of as the CAN controllers’ reaction to a problem on<br />

the bus such as noise, faulty node that includes a bus fault.<br />

What happens if one of the twisted pair opens or is shorted out<br />

CAN has an automatic mechanism for this. Not all transceiver chips<br />

implement all of them. You can usually short CAN Lo to ground (ISO<br />

11898 says CAN short Hi also) or open one CAN line. The ground needs<br />

to be connected for these to function. You cannot short both Hi and<br />

Lo together (Fault Tolerant will work) or open both up. You can cut the<br />

ground or have a large ground loop present and CAN will still work.<br />

These will be detected as a bus error as described above. At least one<br />

node must try to transmit a frame in a bus fault condition to trigger a<br />

bus error. A bus in idle mode cannot trigger a bus error. When the bus<br />

fault is removed, in many systems the network will come back alive,<br />

if so configured. CAN has excellent noise immunity because of the<br />

twisted pair. The common mode noise gets cancelled out and the CAN<br />

signal is not affected (because it is 180 degrees out of phase).<br />

The ground: The ground is not needed for CAN operation if the<br />

twisted pair is intact. This is readily shown with simple experiments.<br />

One experiment showed a small network still worked properly with<br />

two nodes having a 40 volts DC ground difference.<br />

However, it is a good idea to include a good ground in the system<br />

design. Some bus faults need the ground to allow the transceiver<br />

to compensate.<br />

Here are some bonus items that are not part of the CAN specification<br />

that might prove helpful in your system:<br />

1) Transmitting data sets greater than 8 bytes:<br />

Clearly, transmitting a data set greater than 8 bytes will take multiple<br />

frames and this will require some planning. Such schemes can<br />

become very complicated as they have to deal with a wide-ranging<br />

set of contingencies. By focusing on a narrow requirement set, design<br />

of a simpler protocol is possible.<br />

Most current schemes use the first data byte to contain the number of<br />

total data bytes to follow plus a counter to help determine which data<br />

byte is which. The ID usually identifies the node plus whether it is a<br />

request or response message. To use an existing protocol, see ISO<br />

15765. This is what automobiles use. This includes OBDII diagnostics<br />

which is public information. This is a good example where one<br />

message can be comprised of many CAN frames.<br />

2) Periodic, Request/Response and Command Frames:<br />

Periodic: This technique sends a frame out periodically – several<br />

times a second is typical. This frame will contain data that any node<br />

can use and is identified by its ID. Examples are speed, position,<br />

pressure and events.<br />

Request/Response: A node sends out a frame requesting certain<br />

specified information. Any other nodes that have the requested<br />

information then put it on the bus. The ID identifies the Request<br />

frame and the Response by changing one bit of the Request ID. ID<br />

0x248 is a Request frame and 0x648 is its Response. The Request<br />

frame data bytes will specify what information is requested. The<br />

Response frame will contain the requested information or an error<br />

message.<br />

Command: A frame commanding some event is performed. The ID<br />

usually contains the address of the commanded node and the data<br />

bytes the actual command(s). Sometimes an acknowledge frame<br />

is returned.<br />

TIP: Consider a blend of these three types of traffic depending on your<br />

system’s needs.<br />

3) Time-outs:<br />

Automotive CAN networks use time-outs. This concept is easily and<br />

effectively transferred to systems in other fields. A time-out occurs<br />

when a node fails to respond to a request in a timely fashion. Timeouts<br />

are handled completely by software. The CAN specification does<br />

not provide this mechanism. A time-out is helpful to recover from<br />

problems with the network such as severe bus errors, catastrophic<br />

bus faults, faulty nodes or intermittent connections.<br />

www.digikey.ca/microcontroller<br />

51


The result is usually a limp-home mode in which a node will attempt<br />

to run itself without information from the rest of the network. In some<br />

cases, a punitive limp-home mode is entered that forces the user to<br />

perform repairs.<br />

A good example is if the transmission fails and proper shifting<br />

becomes impossible. In this case, the module will go into limp-home<br />

mode and the transmission might be put into one gear, such as<br />

second, to allow the vehicle to still be driven.<br />

This can be for safety reasons or to prevent further damage to the<br />

power train.<br />

Heart-beats and Address Claiming: The other side to a time-out<br />

is a heartbeat. Periodic messages can be sent out to determine that<br />

all nodes are on the bus and active. CANopen uses such heartbeats.<br />

J1939 has a software mechanism in which each node can declare<br />

itself to be on the bus and be recognized by the other nodes. This<br />

is called “Address Claiming” and occurs during the system startup.<br />

These mechanisms are provided by your software.<br />

Sequence of transmitting data on the CAN bus:<br />

1. Any node(s), seeing the bus idle for the required minimum time,<br />

can start sending a CAN frame.<br />

2. All other nodes start receiving it except those also starting to<br />

transmit a message. (They all start at the same time.)<br />

3. If any other node starts transmitting, the priority process starts.<br />

The node with the highest priority continues on and those with a<br />

lesser priority stop sending, immediately turn into a receiver and<br />

receive the higher priority message.<br />

4. At this point, only one node is transmitting a message and no<br />

other nodes will start at this time.<br />

5. When the transmitting node has completed sending its message,<br />

it waits one bit time for the 1-bit ACK fi eld to be pulled to a logic<br />

0 by any other node (or usually all of them) to signify the frame<br />

was received without errors.<br />

6. If this happens, the transmitting node assumes the message<br />

reached its recipient, sends the end-of-frame bits and goes<br />

into receive mode or starts to send its next message if it has<br />

one. The receiving nodes pass the received message to their<br />

host processors for processing unless the acceptance fi ltering<br />

prevents this action.<br />

7. At this time, any node can start sending any messages or the bus<br />

goes into the idle state. Go to 1.<br />

8. If this does not happen (ACK bit not set), then the transmitting<br />

node retransmits the message at the earliest time allowed. If<br />

the ACK bit is never set, the transmitting node will send this<br />

message forever.<br />

Transmitting notes:<br />

• How does a node know when it should transmit a message<br />

Create the CAN frame you want to send by loading up the IDE,<br />

ID, DLC. Any data byte registers in the CAN controller and then,<br />

in most controllers, you set a bit that triggers sending the frame<br />

as soon as legally possible. After this, the controller takes care<br />

of sending all frame bits. Until the controller signals otherwise<br />

to the processor, you can assume the message was sent.<br />

• What if there is an error All nodes, including the transmitting<br />

node, monitor the bus for any errors. If an error condition is<br />

detected, a node (or nodes) signify to the other nodes there is an<br />

error by holding the bus at logical 0 for at least 6 bus cycles. At<br />

this point, all nodes take appropriate action. The message being<br />

sent (and now aborted) will be resent but only a certain number<br />

of times.<br />

• What if no node wants or uses the message Nothing.<br />

The ACK bit only says that the CAN frame was transmitted<br />

without errors and at least one node saw this frame error free.<br />

Remember the transmitting frame cannot ACK itself. CAN does<br />

not provide any acknowledgment mechanism that a frame was<br />

used or not received by its intended recipient. If needed, you will<br />

have to provide this in your software as many systems do.<br />

TIP: In a periodic system, if a node misses a message, it does<br />

not matter much as another copy will be along shortly.<br />

Sequence of receiving data from the CAN bus:<br />

1. All nodes except those currently transmitting frames are in<br />

listening mode.<br />

2. A CAN frame is sent using the procedure as described previously<br />

in “Sequence of Transmitting data on the CAN Bus.”<br />

3. This frame is received by all listening nodes. If deemed to be<br />

a valid CAN message with no errors, the ACK bit is set. In CAN<br />

terminology, the bus is set to the “dominant” state as opposed to<br />

the “recessive” state.<br />

4. The frame is sent through the controller’s acceptance fi lter<br />

mechanism. If this frame is rejected, it is discarded. If accepted,<br />

it is sent to the controller FIFO memory. If the FIFO is full, the<br />

oldest frame is lost.<br />

5. The host processor is alerted when a valid frame is ready to be<br />

read from the FIFO. This is done either by an interrupt or a bit<br />

set in a controller register. This frame must be read as soon as<br />

possible.<br />

6. The host processor decides what to do with this message as<br />

determined by your software.<br />

Receiving notes:<br />

• <br />

is available. Polling is where the host processor “polls” or<br />

continuously tests the bit mentioned in sequence 5. Polling runs<br />

the risk of losing or “dropping” a frame but is sometimes easier to<br />

implement and debug. Interrupts cause the processor to jump to<br />

an interrupt handler in which the frame is read from the controller.<br />

Using interrupts is the recommended method.<br />

• What happens if a message is “dropped” This can cause<br />

some problems as CAN itself does not have a mechanism<br />

for acknowledging a CAN frame. If desired, this must be<br />

added to your software. In the case of Periodic Messages, it<br />

doesn’t normally matter as a replacement message will be<br />

along shortly.<br />

52


• How fast do I have to read the FIFO to not drop messages<br />

<br />

<br />

<br />

<br />

<br />

<br />

CAN controllers and their errata sheets<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Test tools<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Bit stuffing<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

Conclusion<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

CAN demonstration software<br />

<br />

<br />

® <br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

www.digikey.ca/microcontroller<br />

53


STMicroelectronics CAN controller for Cortex-M3 processors<br />

Shown is a block diagram of the CAN controller. Here are the main<br />

points of all CAN controllers:<br />

1. I/O Pins: These connect to the CAN transceiver chip pins R and D<br />

as previously described.<br />

2. Parallel-Serial Converters: CAN is a serial bus while the<br />

processor is parallel. Conversion happens here.<br />

3. Tx mailbox: The messages to be transmitted are written here. ID,<br />

data (if any) and the DLC go here.<br />

4. Acceptance Filter: This passes only specifi ed messages to the<br />

processor via the FIFOs. By default at RESET, these fi lters pass<br />

all messages to the FIFOs. Your software must confi gure them to<br />

fi lter messages.<br />

5. FIFO 0 & 1: Each Receive FIFO can hold three CAN messages.<br />

They provide a buffering system to the processor.<br />

6. Control, Status, Confi guration registers: Your software<br />

must confi gure these registers, usually at initialization.<br />

Various fl ags and switches are found here. Examples are<br />

set CAN speed, request transmission, manage receive<br />

messages, enable interrupts and obtain diagnostic<br />

information. Keil provides examples on how to set and use<br />

these registers.<br />

All CAN controllers have the same basic architecture. Different<br />

controllers will have differences in the number of receive FIFO<br />

buffers, transmit buffers, size of acceptance fi lters and the bit<br />

mapping, addresses and defi nitions of the various confi guration<br />

registers. All CAN controllers are licensed by Robert Bosch GmbH<br />

in Germany and therefore they are able to exert considerable<br />

control over basic CAN attributes to make them consistent with<br />

various manufacturers.<br />

This means that all CAN controllers can communicate with other<br />

brands in a reliable and predictable manner.<br />

Figure 4: STMicroelectronics CAN controller for Cortex-M3 processors.<br />

Keil example CAN program<br />

1. Start μVision by clicking on its<br />

icon on your Desktop.<br />

2. Select Project/Open Project. Open the fi le C:\Keil\ARM\Boards\<br />

Keil\MCBSTM32\CAN\CAN.Uv2.<br />

3. Make sure “Simulator” is selected in the Target window.<br />

4. There is a typo in a source fi le. In the fi le CanDemo.c,<br />

go to line 126. It will probably be:<br />

delay (45000000); // Wait for initial display (~5s)<br />

This delay will be too long. Please change this to a lower value.<br />

45000 works well.<br />

5. Compile the source fi les by clicking on the Build icon.<br />

They will compile with no errors or warnings.<br />

6. Click on the Options for Target icon.<br />

Then, select the Debug tab and confi rm<br />

“Use Simulator” is checked.<br />

7. Enter the Debug mode by clicking on the debug icon.<br />

Select OK when the Evaluation Mode box appears.<br />

8. Position the Toolbox, CAN: Communication and CAN: Controller<br />

windows as appropriate.<br />

9. Click on the RUN icon.<br />

Note: Stop the program<br />

with the STOP icon.<br />

10. Note CAN messages with an ID of 0x21 will appear in the CAN:<br />

Communications window. You can see both the transmit and<br />

receive frames. The CAN controller is in a special Test Mode that<br />

allows it to see its own messages.<br />

11. In the Toolbox window, click on the<br />

“Analog Sweep 0…3.3 V” button.<br />

12. Changing data values representing output from the A/D convertor<br />

will now appear in the CAN messages.<br />

The Keil CAN demonstration software: How it works…<br />

Keil provides a working CAN example with their development tools.<br />

You have already compiled and run this example. You can view and<br />

edit the C source fi les whether in debug mode or not, but to compile<br />

them you must not be in debug mode. This example uses almost no<br />

assembly code as it is (nearly) entirely written in C. Any source fi le<br />

can be opened in μVision, if not already visible, by clicking on File/<br />

Open and selecting it. There are three source fi les we will look at:<br />

Can.h: This fi le defi nes a structure to contain the information used to<br />

construct the CAN frame and create two instances of it.<br />

Can.c: This C code initializes the CAN controller, writes and transmits<br />

a message, receives a message, confi gures the Acceptance Filters<br />

and provides the transmit and receive interrupt handlers.<br />

CanDemo.c: The main function is located in this fi le. CanDemo.c is<br />

the heart of the demonstration program and calls the functions in<br />

Can.C.<br />

54


1) Can.h<br />

The CAN structure CAN_Msg: (lines 23-29, 42 & 43)<br />

The structure declaration in Can.h is shown. You should now be able<br />

to recognize each of these elements. You can enter either an 11- or<br />

29-bit identifier. Two instances of CAN.msg are invoked and are<br />

shown below: CAN_TxMsg and CAN_RxMsg. CanDemo.c writes to<br />

these to create the CAN messages with data.<br />

The prototypes for functions used in Can.c are listed in Can.h in lines<br />

32 to 40. These are visible in μVision.<br />

23 typedef struct {<br />

24 unsigned int id; // 29 bit identifier<br />

25 unsigned char data[8]; // Data field<br />

26 unsigned char len; // Length of data<br />

field in bytes<br />

27 unsigned char format; // 0 - STANDARD,<br />

1- EXTENDED<br />

IDENTIFIER<br />

28 unsigned char type; // 0 - DATA FRAME,<br />

1 - REMOTE FRAME<br />

29 } CAN_msg;<br />

42 extern CAN_msg CAN_TxMsg; // CAN message for<br />

sending<br />

43 extern CAN_msg CAN_RxMsg; // CAN message for<br />

receiving<br />

2) Can.c<br />

Configuring the CAN controller (Can.C)<br />

There are several things that must be done to properly configure the<br />

CAN controller. These are done in Can.C by functions that are called<br />

by CanDemo.c. Examples are found in the function CAN_setup as<br />

shown in μVision:<br />

1. Enable and set the clock for the CAN controller. The clock must<br />

be stable for CAN. No R-C oscillators here.<br />

2. Configure GPIO ports PB8 and PB9 for the transmit and receive<br />

lines to the transceiver chip.<br />

3. Enable the interrupts for the transmit and receive functions.<br />

4. Set CAN_BTR: This is a 32 CAN controller register in which things<br />

such as bit timing, bus frequency, sample point and silent and<br />

loop back modes are set. In the Keil example, the baud rate is<br />

set to 500 Kbps. All CAN controllers on a network should have<br />

consistent BTR values for stable operation.<br />

Sometimes timing settings can cause strange problems. If you<br />

experience some unusual problems, you might want to study CAN<br />

timing in greater detail. For small systems, the default settings<br />

or those suggested by the processor manufacturer will work<br />

satisfactorily. You can adjust these settings for the most robust<br />

bus performance.<br />

All CAN controllers have the same general settings for bit timing<br />

because of the licensing agreements with Robert Bosch GmbH.<br />

For a detailed explanation of CAN bit timing, see www.port.de/pdf/<br />

CAN_Bit_Timing.pdf, and for the calculations, see page 505 of the ST<br />

Reference Manual RM0008.<br />

Other functions in Can.c<br />

• CAN_start: Starts the CAN controller by ending the<br />

initialization sequence.<br />

• CAN_waitReady: Waits until transmit mailbox is ready – then can<br />

add another message to be transmitted.<br />

• CAN_wrMsg: Writes a message to the CAN controller and transmit it.<br />

• CAN_rdMsg: Reads a message from the CAN controller and<br />

releases it to be sent to the STM32 processor.<br />

• CAN_wrFilter: Configures the acceptance filter. This is not<br />

discussed in this article.<br />

• USB_HP_CAN_TX_IRQHandler: The transmit interrupt handler.<br />

• USB_LP_CAN_RX0_IRQHandler: The receive interrupt handler.<br />

These functions are called by CanDemo.c and in the main function.<br />

3) CanDemo.c<br />

This contains the main function and contains the example program that<br />

reads the voltage on the A/D converter and sends its value as a CAN<br />

data byte with an 11-bit ID of 0x21. CanDemo.c contains functions to<br />

configure and read the A/D converter, display the A/D values on the LCD<br />

and call the functions that initialize the CAN controller.<br />

Transmitting a CAN Message:<br />

Lines 131 to 135 put the frame values into the structure CAN_TxMsg.<br />

(Except for the data byte from the A/D converter.)<br />

131 CAN_TxMsg.id = 33; // initialise<br />

message to send<br />

132 for (i = 0; i < 8; i++) CAN_TxMsg.data[i] = 0;<br />

133 CAN_TxMsg.len = 1;<br />

134 CAN_TxMsg.format = STANDARD_FORMAT;<br />

135 CAN_TxMsg.type = DATA_FRAME;<br />

This CAN message will send one data byte. For example, if you<br />

change the value in the member CAN_TxMsg.len to “3,” three data<br />

bytes will be sent on the bus. What data will be in them depends on<br />

the contents of the array CAN_TxMsg.data.<br />

If you send more data bytes than you have data, it is a good idea to fill<br />

the empty data bytes with either 0 or 0xFF.<br />

141 CAN_TxMsg.data[0]= adc_Get (); // data[0] field<br />

= ADC value<br />

142 CAN_wrMsg (&CAN_TxMsg); // transmit<br />

message<br />

143 val_Tx= CAN_TxMsg.data[0]; // send to LCD<br />

screen<br />

Line 141 puts the A/D value into the data member CAN_TxMsg.data in<br />

data byte 0 and line 142 transmits it.<br />

www.digikey.ca/microcontroller<br />

55


Receiving a CAN Message:<br />

Lines 148 to 151 indicate when a CAN message is received, but<br />

something more must be going on here. Line 151 shows that the data<br />

byte received and inserted in the array[0] is sent to be displayed on<br />

the LCD. How exactly does the CAN data byte get into the member<br />

array CAN_RxMsg.data[0]<br />

If you right click on line 210 and select Show Source at Current Line,<br />

this will be displayed in the source fi le.<br />

148 if (CAN_RxRdy) {<br />

149 CAN_RxRdy = 0;<br />

151 val_Rx = CAN_RxMsg.data[0];<br />

It was stated earlier in this article that the function to read the CAN<br />

data was located in Can.c. If we look in Can.c, we fi nd the function<br />

CAN_rdMsg at lines 130 to 159. Examining it, clearly it is here that<br />

the array[0] is loaded at line 148. How does this function get called<br />

It is not called from CanDemo.c.<br />

If we set a breakpoint on Can.c line 132 (the fi rst assembly instruction<br />

of the function CAN_rdMsg) by double-clicking on the left side of Line<br />

132, we can check the Call Stack window to see from where it was<br />

called. This is shown in the screen shot below. This would indicate<br />

line 148 in the main function called CAN_rdMsg. Examining the<br />

assembly code at line 148 shows this cannot be true.<br />

We can use the Trace function of μVision that is available in Simulator<br />

mode to fi gure out how CAN_rdMsg is called.<br />

Figure 5: CAN Call Stack window.<br />

1. Click on Enable Trace Recording icon.<br />

2. Run the program to the breakpoint set previously at line 132.<br />

3. Click on View Trace Records.<br />

View the Disassembly window<br />

that opens up as shown in next window.<br />

The yellow arrow points to the start of the function CAN_rdMsg. The<br />

arrow represents the program counter.<br />

The grey area shows a recording of the instructions that were<br />

executed. The white area displays unexecuted instructions.<br />

Just before line 132 is the source line 213: that calls CAN_rdMsg.<br />

This is actually the assembly instruction at addresses 0x8000A10<br />

BL.W CAN_rdMsg. Reading higher to 210, we can see this source line<br />

comes from the function USB_LP_CAN_RX0_IRQHandler, which is the<br />

Receive Interrupt Handler in Can.c.<br />

So, this interrupt handler called the function that reads the CAN frame<br />

from the CAN controller and inserts it into the structure.<br />

Figure 6: Trace Window showing source code behind current instruction.<br />

If you have more than one CAN controller in your processor, you can<br />

operate these as parallel receivers. Divide the messages with the<br />

Acceptance Filters. This will help capture all the messages on a very<br />

busy bus without losing any. Each CAN controller will handle its share<br />

of the messages. This effectively multiplies the number of FIFO buffer<br />

memories and is an excellent method of getting all the CAN frames.<br />

Exception, PC and data tracing<br />

The ST Cortex-M3 processor possesses signifi cant debugging<br />

capabilities. These features are grouped under the Serial Wire Viewer<br />

and are supported by Keil μVision and the USB-JTAG adapter ULINK2<br />

and ULINK-ME. Recall that Can.c contains two interrupt handlers: for<br />

transmit and receive. These can be displayed in real-time (no CPU<br />

cycles are stolen) in the Trace Records window as shown below. This<br />

works only with a real target Cortex-M3 connected to μVision with a<br />

ULINK2 or ULINLK-ME USB to JTAG adapter.<br />

The Serial Wire Viewer can be used to display PC samples, data read<br />

and write cycles, exceptions and other events. The ITM is a print type<br />

instrumentation output.<br />

To show our example using the Serial Wire Viewer and a STM32 chip:<br />

1. Connect an STM32 processor to μVision and run the same CAN<br />

program using the ULINK Cortex debugger.<br />

2. Activate the Serial Wire Viewer as described in the appendix of<br />

www.keil.com/download/fi les/labst.pdf.<br />

3. Confi gure the Logic Analyzer to display CAN_RxMsg.data[0].<br />

This will also display it in the Trace Records.<br />

4. Set a breakpoint at the instruction at line 148in Can.c. This is the<br />

fi rst instruction after the write to the array CAN_RxMsg. data[0].<br />

This is needed because the instruction the breakpoint is set on is<br />

not executed. We want to see and record this write, so we must<br />

execute this source line.<br />

5. Run the program to the breakpoint. The resulting Exception Trace<br />

window is displayed in Figure 7.<br />

Figure 7: Exception Trace window.<br />

56


Two IRQ events are shown. Note an IRQ is a subset of Exceptions.<br />

Referring to the ST RM0008 reference manual, IRQ 19 is the CAN<br />

Transmit IRQ and IRQ 20 is the Receive IRQ. The Trace Records<br />

window will also be displayed (Figure 8).<br />

Figure 8: Trace Records window.<br />

We can see the following lines:<br />

• 3rd and 4th Line: Exception Entry and Exit: 35: This is the<br />

transmit IRQ. Translate the 35 into IRQ19 in the Exception Trace<br />

window (Figure 6).<br />

• 5th Line: Exception Entry: 36: This is the entry of the receive<br />

IRQ 20 – this is the Receive IRQ Handler.<br />

• 6th Line: Data Write: The value 0x8F is written to address<br />

0c2000004C by the instruction at 0x8004910. You can confi rm<br />

that these values represent an assembly instruction that is<br />

part of source line 148 and that the address written to is<br />

CAN_RxMsg.data[0].<br />

That fi nishes a partial demonstration of the Serial Wire Viewer<br />

trace feature of the Cortex-M3 processor. Visit www.keil.com for<br />

more information concerning the Serial Wire Viewer interface in<br />

Cortex-M3 processors.<br />

An example CAN network<br />

Figure 9 shows a real two-node CAN network using Keil<br />

MCBSTM32 (right) and the MCBSTM32E evaluation boards using the<br />

same example code discussed in this article. The Tx of one node is<br />

transmitted to the Rx of the other node and this is clearly seen on<br />

the LCDs.<br />

Note the twisted differential pair of wires CAN Hi and CAN Lo.<br />

Note that no ground wire is used in this small network.<br />

This setup is part of the Keil lab available for the STM32:<br />

www.keil.com/download/fi les/labst.pdf. Full details are in the lab.<br />

How can I learn more about these CAN examples<br />

With a hardware board, you can generate and receive real CAN<br />

messages and connect to other nodes or a CAN test analyzer. The lab<br />

for the Keil MCBSTM32 board has instructions on how to do this.<br />

This document has some interesting CAN examples. For instance, you<br />

can use the Cortex-M3 Serial Wire Viewer to see the CAN messages<br />

and interrupts displayed in real-time. You can compile these examples<br />

with the evaluation version of the software. Please see www.keil.com/<br />

download/fi les/labst.pdf.<br />

STMicroelectronics supplies a complete software library for<br />

all their peripherals in the STM32 family using the Cortex-M3<br />

processor. This includes CAN support. Search www.st.com/stm32<br />

for STM32F10xFWLib. A zip fi le, UM0427.zip, and an application<br />

note, UM0427.pdf, are available. Keil μVision project and source<br />

fi les are included. There is no charge for these libraries. Keil<br />

uses portions of these libraries in their own examples programs.<br />

These are identifi ed by the letters STLIB in the Keil μVision<br />

project fi lename.<br />

Keil makes NXP evaluation boards with CAN examples. Luminary<br />

Micro also offers some with CAN controllers that are supported<br />

by Keil examples. You now know how CAN works and are familiar<br />

with the Keil software and will have no problem getting a real CAN<br />

system operating. You have already run an accurate simulation<br />

of a CAN network. If you obtain real target hardware, such as the<br />

MCBSTM32, you can also connect up to any CAN network and<br />

communicate with it.<br />

Keil offers a complete CAN stack for all ARM7, ARM9 and<br />

Cortex-M3/M1 processors. This comes as part of RL-ARM. (Please<br />

visit www.keil.com/rl-arm/ for more information.) This comprehensive<br />

package contains the RTX RTOS source (the actual RTOS is already<br />

included free with the MDK toolset), USB, TCP/IP networking and the<br />

CAN interface.<br />

MCBSTM32E Evaluation Board (MCBSTM32EXL-ND)<br />

The Keil MCBSTM32E Evaluation Board introduces you to<br />

the STMicroelectronics Cortex-M3 family of ARM devices<br />

and allows you to create and test working programs for<br />

this advanced architecture. Featuring a QVGA LCD display<br />

plus a wide range of<br />

interfaces such as USB,<br />

CAN, MicroSD Card and<br />

UART, the MCBSTM32E is<br />

a great starting point for<br />

your Cortex-M3 project.<br />

Figure 9: A two node CAN network using Keil MCBSTM32 and the MCBSTM32E<br />

evaluation boards.<br />

www.devtoolsxpress.com<br />

www.digikey.ca/microcontroller<br />

57


Power Debugging ARM Cortex-M3<br />

and Cortex-M4 Applications<br />

by Lotta Frimanson and Anders Lundgren, IAR Systems<br />

Your application is now working properly,<br />

but you’re still over your power budget.<br />

This article shows you how to debug that<br />

problem, too.<br />

Power debugging is a recent innovation that provides software<br />

developers with information about how the software implementation<br />

in an embedded system affects system-level power consumption. By<br />

coupling source code to power consumption, testing and tuning for<br />

power optimization is enabled.<br />

Long battery lifetime is a very important factor for many embedded<br />

systems in almost any market segment--medical, consumer<br />

electronics, home automation, and many more. Power consumption<br />

has traditionally been a design goal that only the hardware developers<br />

have been able to infl uence. But in an active system, power<br />

consumption depends not only on the design of the hardware but also<br />

how it is used, which in turn is controlled by the system software.<br />

The technology for power debugging is based on the ability to<br />

sample power consumption and correlate each sample with the<br />

program’s instruction sequence and hence with the source code.<br />

One diffi culty is achieving high precision sampling. It would be ideal<br />

to be able to sample power consumption with the same frequency<br />

the system clock uses, but power system capacitances reduce the<br />

reliability of such measurements. Usually this is not a problem since<br />

from the software developer’s perspective, it is more interesting<br />

to correlate the power consumption with the source code and<br />

various events in the program execution rather than with individual<br />

instructions, so the resolution needed is much lower than one<br />

sample per instruction.<br />

Typically within the debug probe, a resistor is connected in series with<br />

the supply to the development board. The voltage drop across this<br />

resistor is measured, fed to a differential amplifi er and then sampled<br />

by an A/D converter.<br />

The key to accurate power debugging is a good correlation between<br />

the instruction trace and the power samples. The best correlation can<br />

be achieved if a complete instruction trace is available, as is the case<br />

for ARM MCUs with ETM (Embedded Trace Macrocell) support. The<br />

drawback with using ETM is that it requires a special debug probe<br />

and ETM support in the device itself.<br />

Figure 1: The debug module on Cortex-M3/M4.<br />

Less accurate but still giving good correlation is to use the PC (Program<br />

Counter) sampling facility available in the ARM Cortex-M3/M4 cores<br />

(Figure 1). The DWT (Discrete Wavelet Transform) module implements<br />

the PC sampler; it samples the PC periodically around 10,000 times per<br />

second and triggers an ITM (Instrumentation Trace Macrocell) packet for<br />

each sample taken. The ITM is the formatter for events originating from<br />

the DWT. It packetizes the events and timestamps them. The debug<br />

probe (J-Link Ultra) samples the power consumption of the device using<br />

an A/D converter. By time stamping the sampled power values and the<br />

PC samples, the debugger is able to present power data on the same<br />

time axis as graphs like the interrupt log and variable plots as well as to<br />

correlate power data with the source code.<br />

As stated before, power debugging is based on the ability to sample<br />

the power consumption and correlate each sample with the source<br />

code. For example, in IAR Embedded Workbench the power samples<br />

can be displayed in different formats. The Power Log window (Figure<br />

2) is a log of all collected power samples. This window can be useful<br />

to fi nd peaks in the power sampling, and since the power samples are<br />

correlated with the executed code it is possible to double-click on a<br />

value in the Power Log window and get to the corresponding code.<br />

Figure 2: Power Log window.<br />

58


Figure 3: Timeline window.<br />

Another way of viewing the power samples is via the Timeline window<br />

(Figure 3). In the Timeline window, the power samples are displayed<br />

on a time scale together with the call stack and up to four application<br />

variables that you can select.<br />

Power profiling<br />

On a Cortex-M3 device the debugger can utilize the PC sampling<br />

possibility in the DWT module. This allows the debugger to sample the<br />

PC and provide statistical profiling. The profiler finds the function that<br />

correlates with the sampled PC value and builds an internal database<br />

of how often the functions are executed to generate function profiling<br />

information. The profiling information for each function in an application<br />

will be displayed in a debugger while the application is running.<br />

Low-power mode diagnostics<br />

Many embedded applications spend most of their time waiting for<br />

something to happen: receiving data on a serial port, watching an<br />

I/O pin change state, or waiting for a time delay to expire. If the<br />

processor is still running at full speed when it is idle, battery life is<br />

being consumed while very little is being accomplished. So in many<br />

applications, the microprocessor is only active during a very small<br />

amount of the total time and by placing it in a low-power mode during<br />

the idle time the battery life can be extended by orders of magnitude.<br />

One approach is to have a task-oriented design and to use an<br />

RTOS; in a task-oriented design a task can be defined with the<br />

lowest priority and it will only run when there is no other task that<br />

needs to run. This idle task is the perfect place to implement power<br />

management. In practice every time the idle task is activated it puts<br />

the processor into a low-power mode. Many microprocessors and<br />

other silicon devices have a number of different low-power modes in<br />

which different parts of the processor can be turned off when they are<br />

not needed. The oscillator can, for example, be turned off or switched<br />

to a lower frequency; peripheral units and timers can be turned<br />

off; and the CPU then stops executing instructions. The different<br />

low-power modes have different power consumption rates based on<br />

which peripherals are left on.<br />

Interrupt handling<br />

In an event-driven system, for example, when the system is activated<br />

the power consumption increases as the MCU comes into active<br />

mode along with any peripheral devices. Once execution is suspended<br />

by an interrupt with a higher priority, any peripheral devices that were<br />

already active are not turned off, even though the thread with the<br />

higher priority is not using them. Instead more peripheral devices may<br />

be activated by the new thread, further pushing up consumption.<br />

Even though system performance might be good, more optimizations<br />

can still be made in the power domain. Power debugging will make it<br />

easier to discover the extraordinary increase in power consumption<br />

that occurs when an interrupt hits and identifies it as abnormal. A<br />

closer examination of the Timeline window could have shown that<br />

unused peripheral devices were activated and consuming power for a<br />

longer period than necessary.<br />

DMA versus polled I/O<br />

DMA has traditionally been used to increase transfer speed. In the<br />

MCU world chip vendors have invented a plethora of DMA techniques<br />

to increase flexibility and speed and to lower power consumption. In<br />

some architectures the CPU can even be put into sleep mode during<br />

the DMA transfer. Power debugging allows the developer to experiment<br />

and see directly in the debugger what effects these DMA techniques<br />

will have compared to a traditional CPU-driven polled approach.<br />

Finding conflicting hardware setups<br />

To avoid floating inputs it is a common design practice to tie unused<br />

MCU I/O pins to ground. If the software by mistake configures one of<br />

the grounded I/O pins as a logical ‘1’ output, a current as high as 25<br />

mA may be drained on that pin. This high unexpected current is easily<br />

observed by reading the current value from the power graph; it is also<br />

possible to find the corresponding erratic initialization code by looking<br />

at the power graph at application startup. A similar situation will arise<br />

if an I/O pin is designed to be an input and is driven by an external<br />

circuit, but the software incorrectly configures the input pin as output.<br />

Waiting for device status<br />

One common mistake that could cause unnecessary power to be<br />

consumed is to use a poll loop to wait for a status change of, for<br />

example, a peripheral device. While code constructions execute<br />

without interruption until the status value changes into the expected<br />

state. Another related code construction is the implementation of a<br />

software delay as a for or while loop.<br />

In both of these situations the code could be changed to minimize the<br />

power consumption. Time delays are better implemented by using a<br />

hardware timer. The timer interrupt is set up and after that the CPU goes<br />

into a low-power mode until it is awakened by the interrupt. Also a polling<br />

of a device status change should be solved with interrupts if possible or<br />

by using a timer interrupt so that the CPU can sleep between the polls.<br />

Depending on the characteristics of the embedded system it could<br />

be difficult to find these situations using power debugging. One way<br />

forward is to use the different power debugging windows to get to<br />

know the power profile of the application so that abnormal behavior<br />

can more easily be identified.<br />

Finally, power debugging allows the developer to verify the power<br />

consumption as a factor of the clock frequency. A system that spends<br />

very little time in sleep mode at 50 MHz is expected to spend 50 percent<br />

of the time in sleep mode when running at 100 MHz. The power data in<br />

the debugger will allow the developer to verify expected behavior and<br />

if nonlinear dependency on the clock frequency exists, to choose the<br />

operating frequency that gives the lowest power consumption. Power<br />

consumption in a CMOS MCU is theoretically given by the formula:<br />

PPPP = ffff ∗ UUUU2 ∗ kkkk<br />

where f is the clock frequency, U is the supply voltage and k is a<br />

constant.<br />

www.digikey.ca/microcontroller<br />

59


Analog interference<br />

Mixing analog and digital circuits on the same board has its own<br />

challenges. Board layout and routing become important in order<br />

to keep the analog noise levels at a low level in order to ensure<br />

accurate sampling of low-level analog signals. Doing a good<br />

mixed-signal design requires careful hardware considerations and<br />

skills. Software design can also affect the quality of the analog<br />

measurements. Performing a lot of I/O activity at the same time<br />

as sampling analog signals will cause many digital lines to toggle<br />

state at the same time – a candidate for introducing extra noise<br />

into the A/D converter.<br />

Power debugging will help to identify interference from digital and<br />

power supply lines affecting the analog parts. Interrupt activity<br />

can easily be displayed in the Timeline window together with<br />

power data. Be sure to study the power graph right before the A/D<br />

converter interrupts. Power spikes in the vicinity of A/D conversions<br />

could be the source of noise and must be investigated. All data<br />

presented in the timeline window is correlated to the executed<br />

code; simply double-clicking on a suspicious power sample will<br />

bring up the corresponding C source code.<br />

Conclusion<br />

Power debugging techniques provide embedded developers the<br />

ability to understand the effect of source code on their application’s<br />

power consumption. By careful analysis of power “hot spots” and<br />

the review of programming methods used, engineers can make<br />

signifi cant battery lifetime savings even during the early stages of<br />

project development.<br />

Figure 4: Power spike due to stepper motor interfering with A/D-sampling.<br />

We’re changing how engineers think about<br />

design using Cortex-M0 solutions with:<br />

Lowest active power – as low as 130 μA/MHz<br />

Superior Code Density – 50% less code for most tasks<br />

Higher performance – LPC1100 runs at over 45 DMIPS<br />

Smallest size – the LPC1102 has a footprint of 5 mm 2<br />

Low-cost toolchain – LPCXpresso for less than $30<br />

Cortex-M0: a simple choice<br />

www.digikey.ca/nxp-mcu<br />

60


The Heartbeat Behind Portable<br />

Medical Devices: Ultra-Low-Power<br />

Mixed-Signal <strong>Microcontroller</strong>s<br />

by Shahram Tadayon, Silicon Laboratories<br />

Low-power, low-noise, low-cost MCUs are<br />

powering the next generation of portable<br />

medical devices.<br />

The proliferation of sophisticated yet affordable personal medical devices is<br />

transforming the health care industry, enabling consumers to monitor vital<br />

signs and other key aspects of their health at home and on the go without<br />

costly and inconvenient visits to the doctor’s office. According to Gartner,<br />

Inc., portable consumer medical devices such as blood glucose monitors,<br />

blood pressure monitors, insulin pumps, and heart rate monitors, represent<br />

the fastest-growing segment in the medical equipment market. A recent<br />

medical semiconductor report by Databeans projects that the home medical<br />

device segment will experience a compound annual growth rate (CAGR) of<br />

nine percent over the next five years.<br />

The explosive growth of the personal medical device market stems<br />

from a variety of factors: a steadily “graying” (aging) population<br />

requiring more frequent health monitoring; skyrocketing costs of<br />

traditional physician-directed medical care; growing consumer<br />

awareness of the benefits of wellness products; widespread<br />

availability of personal medical devices, both online and in<br />

retail outlets; and the increasing sophistication, ease of use and<br />

affordability of consumer health care products enabled by continuing<br />

advances in semiconductor technology.<br />

While consumer products are generally price sensitive, the consumer<br />

portable health market adds other stringent requirements in order<br />

for devices to be successful in the market. Above all, they must be<br />

highly reliable and accurate in order to detect and help prevent health<br />

problems. These requirements are regulated by government entities<br />

such as the Food and Drug Administration (FDA) in the United States.<br />

In order to succeed in the increasingly competitive home health care<br />

market, portable medical devices should offer the following features:<br />

• Ease of use<br />

• Highly reliable and safe (government-regulated) operation<br />

• Easy, secure connectivity<br />

• Low-power operation (long battery life)<br />

• Support for a wide range of voltages (especially lower voltages)<br />

• High measurement accuracy<br />

• Small form factors<br />

• Affordable cost<br />

To be able to deliver this array of product features to consumers at<br />

economical prices, medical device developers must reduce system<br />

cost by limiting the number of discrete components within the<br />

design. Semiconductor suppliers also are tasked with supplying<br />

highly integrated embedded control solutions that enable increased<br />

performance and reliability within strict power and cost budgets.<br />

At the heart of these portable device designs are highly integrated<br />

mixed-signal microcontrollers (MCUs) designed to deliver exceptional<br />

processing performance at the lowest supply currents.<br />

Ease of use is essential for all portable medical products because it<br />

reduces errors in measurement resulting from operator error. Such<br />

devices should require minimal user interaction for proper operation,<br />

simple user input (for example, fewer buttons and simpler software<br />

menus) and large, backlit easy-to-read displays. To support these<br />

features, MCUs must provide field-programmable, non-volatile<br />

memory storage (typically in-system programmable flash memory),<br />

as well as flexible I/O configurations to make the best use of a limited<br />

number of pins.<br />

While many portable medical devices today simply display health<br />

monitoring results and leave the interpretation and logging to end users<br />

and their physicians, newer devices feature simple connectivity to log<br />

and transmit results automatically. Typically, these more sophisticated<br />

products will connect to personal computers or mobile health<br />

appliances with software that can track results, or they will securely<br />

transmit information wirelessly to medical professionals, caretakers or<br />

web-based applications – a practice known as telemedicine.<br />

The health care equipment market has adopted an optimized USB<br />

device standard, the Personal Health Care Device (PHCD) Class<br />

(Figure 1), which leverages the ubiquitous USB interface to enable<br />

standardized transmission of data and messages regardless of device<br />

manufacturer. Moving forward, wireless transmission of data<br />

Figure 1: USB personal healthcare device class supports easy connectivity.<br />

www.digikey.ca/microcontroller<br />

61


will make connectivity even easier with simple, yet reliable wireless<br />

connections for even greater convenience. MCUs will need to provide<br />

a variety of integrated connectivity interface methods, such as<br />

integrated USB controllers with precision oscillators.<br />

RF transmitters and transceivers working in concert with MCUs<br />

can enable wireless connectivity for telemedicine applications. In<br />

addition, wireless MCUs – highly integrated devices that combine<br />

a low-power MCU core with a high-performance RF transceiver in<br />

the same package – are now widely available. Silicon Labs’ Si10xx<br />

wireless MCUs, for example, provide the ultra-low-power operation<br />

required by battery-powered portable medical applications, coupled<br />

with extended range and exceptional RF sensitivity enabled by an<br />

integrated sub-GHz transceiver.<br />

Whatever the connectivity method or system architecture used,<br />

communication protocol stacks will require more code space in the<br />

MCU. As a result, more memory in smaller footprint devices will be in<br />

greater demand.<br />

While choices in high-performance, low-power MCUs and<br />

communications options will be important, all medical devices will<br />

need to accurately and consistently measure and some aspect of a<br />

person’s health, be it light (for blood oxygen), conductivity (for blood<br />

glucose), pressure (for blood pressure), or temperature. In the health<br />

care market, there is simply no room for errors in measurement.<br />

Mixed-signal MCUs must give superior analog voltage measurement<br />

results in the presence of noisy digital processor and communications<br />

signals in small spaces. This is one of the most challenging<br />

engineering problems faced by semiconductor suppliers, and such<br />

specifi cations will be scrutinized by product engineers, especially<br />

when faced with low battery voltages for the IC. Measurements must<br />

be low in noise and distortion (good signal-to-noise and distortion<br />

ratios) and highly linear. Analog-to-digital converter (ADC) operation<br />

must be allowed even when the MCU is in operation; the end user<br />

will expect to observe functions during measurement, and it is likely<br />

that the MCU will interpret results in real time. Furthermore, all chip<br />

features should be permitted even at the lowest battery voltages;<br />

what good is the MCU if you cannot make a measurement over the<br />

full battery life In short, MCU suppliers in this market must integrate<br />

accurate analog measurements without compromise.<br />

The next design challenge for the MCU supplier is the demand for<br />

long battery life in the end product. “Portable” generally means that<br />

the device is battery powered. Typically, added features result in<br />

greater power consumption, but developers will not design a portable<br />

medical product that requires end users to use large, heavy batteries<br />

or to change them frequently.<br />

MCUs must support three parts of a low-power strategy: low-power<br />

while in active mode, low-power while in standby mode and reduced<br />

time in an active state. The portable device, and thus the MCU, will<br />

be in an off or lower power state most of the time; however, it will<br />

often maintain some sort of function such as a clock/calendar or<br />

alarm when not in use. While active power consumption is important,<br />

minimizing the time awake is the key to extending battery life. MCU<br />

designers must engineer ways to wake the MCU clock and analog<br />

circuits for fast measurements and then allow the MCU to settle back<br />

to a low-power state. For example, making a voltage measurement<br />

with an ADC requires a voltage reference. Such voltage references<br />

typically require tens of milliseconds to turn on and stabilize before<br />

a measurement can be made. During this time the MCU is on and<br />

draining the battery.<br />

Silicon Labs’ ultra-low-power C8051F9xx MCUs (Figure 2) wake up<br />

in microseconds like many power-effi cient MCUs, but the on-chip<br />

voltage reference is designed to also wake within 2 microseconds,<br />

allowing accurate ADC measurements to begin quickly. The ADC is<br />

also designed to rapidly accumulate many measurements without<br />

CPU intervention for improved results while further minimizing time<br />

awake. The less time awake, the less current is drawn from the<br />

battery while giving good results.<br />

Figure 2: Fast wake times and short operation intervals will extend battery life.<br />

Another important trend in MCU design involves supporting new<br />

battery use confi gurations and technologies (Figure 3). Rechargeable<br />

batteries are popular and typically need higher voltage support, so<br />

integrated on-chip voltage regulators are mandatory. An emerging<br />

trend is to use only one alkaline battery to reduce product size or to<br />

save cost when the end user expects the supplier to ship an installed<br />

battery. Until recently, this approach required the added cost and<br />

space of a discrete DC-DC switching regulator to boost the alkaline<br />

battery voltage for proper MCU operation (alkaline batteries have a<br />

useful life to 0.9 V). Not only do these switching regulators create a<br />

large amount of noise in voltage measurements, they must remain<br />

on at all times to allow the MCU to wake from sleep mode, thereby<br />

draining power and reducing battery life.<br />

Sophisticated low-power MCUs such as Silicon Labs F9xx devices include<br />

an integrated DC-DC regulator that addresses these issues. The result is<br />

lower noise, less cost, reduced footprint, and better control, allowing the<br />

DC-DC regulator to be off while the MCU is in its low-power state, thus<br />

extending battery life. Even though this DC-DC regulator is integrated, it<br />

should still output the boosted voltage supply externally to the rest of the<br />

system for a true low-power, single-battery solution.<br />

Figure 3: MCUs should support a wide range of voltages supplied by batteries.<br />

62


While MCU suppliers continue to innovate and integrate powerand<br />

battery-saving features, the trend toward energy effi ciency<br />

would not be fully advantageous if the cost and footprint of<br />

the MCU grew substantially. The goal is to help the embedded<br />

developer deliver a lower cost, smaller end product as well as<br />

reduce power consumption. Such solutions must reduce the bill<br />

of materials and device size. The best MCUs will deliver plenty<br />

of performance, integrated connectivity, memory and superior<br />

analog peripherals in the smallest form factors. In other words,<br />

semiconductor suppliers must provide increased functional<br />

density without compromise.<br />

Note the ultra-low-power MCU example in Figure 4 – 64 kB of fl ash<br />

code storage, 4 kB of data RAM, an ADC, and two voltage regulators<br />

(LDO and DC-DC boost convertor) within a 4 mm x 4 mm footprint<br />

(in some cases even smaller). This compact mixed-signal MCU<br />

design allows a complete measurement and interface system on a<br />

single chip without sacrifi cing performance or battery life. Product<br />

designers will be careful to choose MCUs like this with the right set<br />

of peripherals to obtain the optimal cost/performance benefi t.<br />

Embedded developers and product managers are under<br />

continuous pressure to push the envelope of reduced cost, size,<br />

power consumption, and increased performance in their portable<br />

medical device designs. The answer is to use highly integrated<br />

mixed-signal MCUs to deliver products to a market that demands<br />

the very best in performance and affordability in the smallest form<br />

factors. Functionally dense mixed-signal MCUs will provide the<br />

heartbeat for the next generation of portable medical devices, and<br />

health care equipment makers that deliver optimized products that<br />

meet consumer needs will enjoy the benefits of this fast-growing<br />

market segment.<br />

Figure 4: F9xx ultra-low-power MCU architecture.<br />

megaAVR: The Next Step in Capacity and Performance<br />

When your designs need some extra muscle, you need the megaAVR. Ideal for<br />

applications requiring large amounts of code, the megaAVR offers substantial<br />

program and data memories with performance up to 20 MIPS. Innovative<br />

picoPower technology minimizes power consumption. All megaAVRs offer<br />

self-programmability for fast, secure, cost-effective in-circuit upgrades. You<br />

can even upgrade the fl ash while running your application.<br />

Based on industry-leading, proven technology, the megaAVR family offers our<br />

widest selection of devices in terms of memories, pin counts and peripherals.<br />

Choose from general-purpose devices to models with specialized peripherals<br />

like USB, or LCD controllers, or CAN, LIN and Power Stage Controllers. It’s<br />

easy to fi nd the perfect fi t for your project in the megaAVR product family.<br />

Key Features<br />

• Broad family — megaAVR offers our widest selection of devices in<br />

terms of memories, pin counts and peripherals, enabling reuse of code<br />

and knowledge across projects.<br />

• picoPower technology — Selected megaAVR features ultra-lowpower<br />

consumption and individually selectable low-power sleep modes<br />

that make it ideal for battery-powered applications.<br />

• High integration — The megaAVR features on-chip fl ash, SRAM,<br />

internal EEPROM, SPI, TWI, and USART, USB, CAN, and LIN, watchdog<br />

timer, a choice of internal or external precision oscillator, and general<br />

purpose I/O pins, simplifying your design and reducing bill-of-materials.<br />

• Analog functions — Advanced analog capabilities, such as ADC, DAC,<br />

built-in temperature sensor and internal voltage reference, brown<br />

out detector, a fast analog comparator and a programmable analog<br />

gain amplifi er. The high level of integration allows designs with fewer<br />

external analog components.<br />

• Rapid development — megaAVR microcontrollers speed development<br />

with powerful in-system programming and on-chip debug. In addition,<br />

in-system programming simplifi es production line programming and<br />

fi eld upgrades<br />

www.digikey.ca/atmel-mcu<br />

www.digikey.ca/microcontroller<br />

63


USB 3.0—<br />

Are We There Yet<br />

by John Donovan, Low-Power Design<br />

SuperSpeed USB may be slow out of the blocks,<br />

but with a 10x speed advantage and lower power<br />

profile than its predecessors, its compelling<br />

advantages make it look like a sure winner.<br />

Firewire 800<br />

Firewire 400<br />

0.2<br />

0.2<br />

49.6<br />

31.6<br />

39.3<br />

39.9<br />

40<br />

73.6<br />

74.5<br />

75.8<br />

If there was a universal serial bus in 1995, it was RS-232. Every PC in the<br />

world had one, although you could connect only one device to it at a time.<br />

Reconfiguring the port for new devices and/or applications required you<br />

to either be a “power user” or have an engineering degree.<br />

In January 1996, Intel introduced the Universal Serial Bus (USB), a<br />

bidirectional, low-cost, low- to mid-speed peripheral bus that could<br />

support as many as 127 devices, all of which could be added to the<br />

bus in “plug-and-play” (initially “plug-and-pray”) fashion. USB 1.0<br />

supported a data transfer rate of 12 Mb/s, which worked well for disk<br />

drives. In 1998, USB 1.1 added a slower (1.5 Mb/s) rate to support<br />

keyboards, mice, and other human-interface devices (HID).<br />

Addressing the need for speed, the USB 2.0 specifi cation was released<br />

in 2000 and standardized in 2001, promising a data rate of 480 Mb/s.<br />

However, because of the overhead involved in the protocol and USB’s<br />

heavy reliance on the processor for transaction arbitration and scheduling,<br />

speeds closer to half that rate were more typical. Still, a theoretical 40x<br />

increase in bus speed in four years was pretty impressive.<br />

USB has since become the most successful PC peripheral<br />

interconnect ever defi ned, with over 10 billion USB 2.0 products<br />

installed today, a number that is rising rapidly. In-Stat predicts that<br />

nearly 4.5 billion USB ports will ship in 2014, of which 1.7 billion will<br />

support the new “SuperSpeed” USB 3.0 spec.<br />

Facing competition from other high-speed interconnect protocols<br />

(Figure 1), like 400 and 800 Mbps IEEE-1394 (FireWire) and HDMI<br />

(both of which targeted high-data rate streaming of video), the USB<br />

Implementers Forum (USB-IF) formalized the specifi cation for USB 3.0<br />

in 2008, which promises a “SuperSpeed” data rate of 5 Gb/sec, a 10x<br />

improvement over USB 2.0.<br />

Design goals<br />

With USB 2.0 having become universal, the key goal was to make<br />

it faster. Since smart phone users can now sideload video fi les ten<br />

times faster, this will supposedly keep HDMI or FireWire sockets from<br />

proliferating on these devices.<br />

SATA 3Gbps (direct)<br />

eSATA<br />

USB 2.0<br />

Access Time (ms)<br />

Average Read (MB/s)<br />

Read Burst (MB/s)<br />

Max Read (MB/s) USB 3.0<br />

Min Read (MB/s)<br />

The primary goals for USB 3.0 are to:<br />

• Preserve the USB model of smart host and simple device.<br />

• Leverage the existing USB infrastructure. This means<br />

maintaining the same software architecture and easing the<br />

migration from legacy products.<br />

• Improve power management.<br />

• Maintain ease-of-use.<br />

• Preserve users’ investment in USB 2.0 devices.<br />

0.1<br />

0.1<br />

0.2<br />

0.1<br />

0 50<br />

29.8<br />

36.3<br />

36.8<br />

36.8<br />

Figure 1: Communications protocols speed comparison.<br />

With minor modifi cations, USB software stacks will continue to<br />

recognize the following three device classes:<br />

• Communications Device Class (CDC), which presents the USB<br />

port to an application as a standard COM port. Supporting bulk<br />

transfers, the CDC provides high-bandwidth with a reasonable<br />

amount of simplicity.<br />

• Human Interface Device (HID) Class, which supports mice,<br />

keyboards, touchscreens and other input devices. Bandwidth is<br />

limited to 64 kb/s.<br />

• Mass Storage Class (MSC), which supports moving large<br />

amounts of data to and from fl ash drives, digital cameras, and<br />

fl ash card readers.<br />

69.8<br />

99.6<br />

91.7<br />

119.8<br />

120<br />

121.1<br />

194.5<br />

227.9<br />

216.3<br />

184.4<br />

196.8<br />

213.1<br />

100 150 200 250<br />

64


USB 3.0 is clearly overkill for HID applications, but it’s definitely a<br />

new contender for embedded CDC and MSC applications, particularly<br />

those involving streaming high-definition video. Its power advantage<br />

over legacy USB makes it a serious consideration for portable devices.<br />

Architectural innovations<br />

Achieving a 10x speed improvement while reducing power<br />

consumption involved making serious architectural changes to both<br />

the protocol and associated hardware. At the same time, some tradeoffs<br />

(and clever workarounds) were necessary to maintain backward<br />

compatibility with legacy USB 2.0 products.<br />

For starters, USB 3.0 maintains the same tiered star topology as USB 2.0,<br />

maintaining compatibility by adding two more twisted pairs to the<br />

cable to supplement the USB 2.0 data pair, which is left untouched.<br />

The two additional signal pairs create a dual simplex SuperSpeed<br />

data path, with one pair for transmit and one for receive. This enables<br />

backward compatibility by including both SuperSpeed and non-<br />

SuperSpeed bus interfaces.<br />

Super<br />

Speed<br />

SuperSpeed<br />

Extended<br />

Connector(s)<br />

SuperSpeed<br />

Function<br />

High-<br />

Speed<br />

SuperSpeed<br />

Hub<br />

Non-SuperSpeed<br />

Full-<br />

Speed<br />

Non-<br />

SuperSpeed<br />

Function<br />

USB 2.0<br />

Hub<br />

Low-<br />

Speed<br />

USB 3.0 Hub<br />

USB 3.0 Host<br />

Extended<br />

Connector(s)<br />

Non-SuperSpeed<br />

(USB 2.0)<br />

Composite Cable<br />

USB 3.0 Peripheral Device<br />

Note: Simultaneous operation of SuperSpeed and non-SuperSpeed<br />

modes is not allowed for peripheral devices<br />

Figure 2: USB 3.0 dual-bus architecture. (Used with permission from USB-IF).<br />

Polling is also eliminated. A USB 2.0 host continuously polls all<br />

peripheral devices to see if they have data to send to the host<br />

controller. All devices must therefore be on at all times, which not only<br />

wastes power but adds unnecessary traffic to the bus. In USB 3.0,<br />

polling is replaced by asynchronous notification. The host waits until<br />

an application tells it that there is a peripheral with data it needs to<br />

send to the host. The host then contacts that peripheral and requests<br />

that it send the data. When both are ready, the data is transferred.<br />

USB 2.0 is inherently a broadcast protocol. USB 3.0 uses directed<br />

data transfer to and from the host and only the target peripheral. Only<br />

that peripheral turns on its transceiver, while others on the bus remain<br />

in powered-down mode.<br />

Numerous innovations in the USB 3.0 architecture set it apart from its<br />

predecessors (Figure 3).<br />

Chip to Chip Port-to-Port End-to-End<br />

Host<br />

Device Driver/Application<br />

USB System Software<br />

Notifications<br />

Transaction<br />

Packets<br />

Transactions<br />

Data<br />

Packets<br />

Link Management Packets<br />

Pkt<br />

Delims<br />

8b/10b<br />

encode/<br />

decode<br />

Spread<br />

Clock CDR<br />

Link Control/Mgmt<br />

Link Cmds<br />

Scramble/<br />

descramble<br />

LFPS<br />

Elasticity<br />

Buffer/Skips<br />

Hub<br />

Pipe Bundle (per Function Interface)<br />

Pkt<br />

Delims<br />

8b/10b<br />

encode/<br />

decode<br />

Default Control Pipe<br />

Spread<br />

Clock CDR<br />

Link Control/Mgmt<br />

Link Cmds<br />

Scramble/<br />

descramble<br />

LFPS<br />

Elasticity<br />

Buffer/Skips<br />

Notifications<br />

PHY<br />

The SuperSpeed USB physical connection is comprised of two<br />

differential data pairs: one transmit path and one receive path, both<br />

operating at 5 GB/s. Each differential link is initialized by enabling<br />

its receiver termination. In the absence of signaling, low frequency<br />

periodic signaling (LFPS) is used to signal initialization and power<br />

management information. Data is packetized and passed directly to<br />

the intended receiver. Since USB 3.0 does not include a reference<br />

clock, each PHY has its own clock domain with spread spectrum<br />

clocking (SSC) modulation. The transmitter encodes data and control<br />

characters into symbols using an 8b/10b code, ensuring enough<br />

transitions that the receiver can accurately recover clock and data.<br />

Link layer<br />

SuperSpeed USB moves firmly into the realm of high-speed packet<br />

processing. The link layer handles link initialization and flow control,<br />

packet framing, link power management and error detection, and<br />

recovery. There are separate Link Management Packets (LMP),<br />

Transaction Packets (TP), Isochronous Timestamp Packets (ITP) and<br />

Data Packets (DP); all start with a distinct 14 byte header packet,<br />

consisting of 12 bytes of header information and a two byte CRC-16<br />

code. This is not your dad’s USB.<br />

Protocol layer<br />

SuperSpeed USB is not a polled protocol, as devices may<br />

asynchronously transmit notifications to the host. Host-transmitted<br />

protocol packets are routed through intervening hubs, taking a direct<br />

path to a peripheral device. The transmitter can transmit multiple<br />

bursts of back-to-back sequences of data packets, while the receiver<br />

can simultaneously transmit data acknowledgements without<br />

interrupting the burst of data packets. This is a far more efficient use<br />

of bus bandwidth than the half-duplex, non-bursting nature of traffic<br />

on earlier USB buses.<br />

Table 1 summarizes the main differences between high-speed USB<br />

2.0 and SuperSpeed 3.0.<br />

Power management<br />

First, SuperSpeed makes more power available to connected<br />

devices. The amount of power available on the USB bus (for<br />

recharging cell phones and other portable devices, for example)<br />

is increased from 5 V @ 500 mA in USB 2.0 to 5 V @ 900 mA for<br />

USB 3.0. This is a distinct advantage as more portable devices have<br />

come to rely on the USB bus not just for data transfer but also for<br />

battery recharging.<br />

Device<br />

Transaction<br />

Packets<br />

Function<br />

Device<br />

Transactions<br />

Data<br />

Packets<br />

Link Management Packets<br />

Pkt<br />

Delims<br />

8b/10b<br />

encode/<br />

decode<br />

Spread<br />

Clock CDR<br />

Link Control/Mgmt<br />

Link Cmds<br />

Scramble/<br />

descramble<br />

LFPS<br />

Elasticity<br />

Buffer/Skips<br />

Figure 3: USB 3.0 logical architecture. (Used with permission from USB-IF).<br />

USB Function<br />

Power<br />

Management<br />

USB Device<br />

Power<br />

Management<br />

(Suspend)<br />

Localized<br />

Link Power<br />

Management<br />

Device or Host PROTOCOL LINK PHYSICAL<br />

www.digikey.ca/microcontroller<br />

65


Table 1: USB 2.0 versus 3.0. (Used with permission from USB-IF).<br />

Characteristic USB 2.0 USB 3.0<br />

Data rate Low-speed (1.5 Mbps), full-speed (12<br />

Mbps), and high-speed (480 Mbps).<br />

Data<br />

interface<br />

Cable signal<br />

count<br />

Bus transaction<br />

protocol<br />

Power<br />

management<br />

Bus power<br />

Port state<br />

Data transfer<br />

types<br />

Half-duplex, two-wire differential<br />

signaling. Unidirectional data fl ow<br />

with negotiated directional bus<br />

transitions.<br />

Two: two for low-/full-/high- speed<br />

data path.<br />

Host directed, polled traffic flow. Packet<br />

traffic is broadcast to all devices.<br />

Port-level suspend with tow levels<br />

of entry/exit latency. Device-level<br />

power management.<br />

Support for low/high bus-powered<br />

devices with lower power limits for<br />

unconfigured and suspended devices.<br />

Port hardware detects connect<br />

events. System software uses port<br />

command to transitions the port<br />

into an enabled state (USB data<br />

communication fl ows).<br />

Four data transfer types: control,<br />

bulk, Interrupt, and Isochronous.<br />

SuperSpeed (5.0 Gpbs).<br />

Dual-simplex, four-wire differential<br />

signaling separate from USB<br />

2.0 signaling. Simultaneous<br />

bi-directional data fl ows.<br />

Six: four for SuperSpeed data path.<br />

Two for non-SuperSpeed data path.<br />

Host directed, asynchronous traffi c<br />

fl ow. Packet traffi c is explicitly routed.<br />

Multi-level link power management<br />

supporting idle, sleep, and suspend<br />

states. Link-, Device-, and Functionlevel<br />

power management.<br />

Same as for USB 2.0 with a 50%<br />

increase for unconfigured power and<br />

an 80% increase for configured power.<br />

Port hardware detects connect<br />

events and brings the port into<br />

operational state ready for<br />

SuperSpeed data communication.<br />

USB 2.0 types with SuperSpeed<br />

constraints. Bulk has streams<br />

capability.<br />

More importantly, SuperSpeed USB enables considerable power<br />

savings by enabling both upstream and downstream ports to initiate<br />

lower power states on the link. In addition, multiple link power<br />

states are defi ned, enabling local power management control and,<br />

therefore, improved power usage effi ciency. Eliminating polling<br />

and broadcasting also went a long way toward reducing power<br />

requirements. Finally, the increased speed and effi ciency of USB<br />

3.0 bus, combined with the ability to use data streaming for bulk<br />

transfers, further reduces the power profi le of these devices.<br />

Typically, the faster a data transfer completes, the faster system<br />

components can return to a low-power state. The USB-IF estimates<br />

the system power necessary to complete a 20 MB SuperSpeed data<br />

transfer will be 25 percent lower than is possible using USB 2.0.<br />

The SuperSpeed specifi cation brings over Link Power Management<br />

(LPM) from USB 2.0. LPM was fi rst introduced in the Enhanced Host<br />

Controller Interface (EHCI) to accommodate high-speed, PCI-based<br />

USB interfaces. Because of the diffi culty of implementing it, LPM was<br />

slow to appear in USB 2.0 devices. It is now required in USB 3.0 and<br />

for SuperSpeed devices supporting legacy high-speed peripherals.<br />

LPM is an adaptive power management model that uses link-state<br />

awareness to reduce power usage.<br />

LPM defi nes a fast host transition from an enabled state to L1<br />

Sleep (~10 µs) or L2 Suspend (after 3 ms of inactivity). Return from<br />

L1 sleep varies from ~70 µs to 1 ms; return from L2 Suspend mode is<br />

OS dependent. The fast transitions and close control of power at the<br />

link level enables LPM to manage power consumption in SuperSpeed<br />

systems with greater precision than was previously possible.<br />

Link power management enables a link to be placed into a lower<br />

power state when the link partners are idle. The longer a pair of<br />

link partners remain idle, the deeper the power savings that can<br />

be achieved by progressing from UO (link active) to Ul (link standby<br />

with fast exit) to U2 (link standby with slower exit), and fi nally to U3<br />

(suspend). Table 2 summarizes the logical link states.<br />

Table 2: Logical link states. (Used with permission from USB-IF).<br />

Link State Description Key Characteristics Device Clock Exit Latency<br />

U0 Link active - On N/A<br />

U1 Link idle, fast exit RX & TX quiesced On or off µs<br />

U2 Link idle, slow exit Clock gen circuit also On or off µs-ms<br />

quiesced<br />

U3 Suspend Portions of device power<br />

removed<br />

Off<br />

ms<br />

Most SuperSpeed devices, sensing inactivity on the link, will<br />

automatically reduce power to the PHY and transition from U0 to U1.<br />

Further inactivity will cause these devices to progressively lower<br />

power. The host or devices may further idle the link (U2), or the host<br />

may even suspend it (U3).<br />

Both devices and downstream ports can initiate Ul and U2 entry.<br />

Downstream ports have inactivity timers used to initiate Ul and U2<br />

entry. Downstream port inactivity timeouts are programmed by system<br />

software. Devices may have additional information available that they can<br />

use to decide to initiate Ul or U2 entry more aggressively than inactivity<br />

timers. Devices can save significant power by initiating Ul or U2 more<br />

aggressively rather than waiting for downstream port inactivity timeouts.<br />

While the advantages of SuperSpeed USB are impressive, these<br />

devices are just beginning to appear in a world dominated by USB 2.0.<br />

For backward, compatibility SuperSpeed devices must support both<br />

USB 2.0 and 3.0 link speeds, maintaining separate controllers and<br />

PHYs for full-speed, high-speed and SuperSpeed links. By maintaining<br />

a parallel system to support legacy devices, SuperSpeed’s designers<br />

accepted higher cost and complexity as a price worth paying to avoid<br />

compromising the speed advantage of their new architecture.<br />

Adoption ramp<br />

No new standard, whatever its technical advantages, is adopted<br />

overnight. That is certainly true with USB 3.0, which needs to<br />

see a critical mass of devices in the fi eld before it will take off.<br />

Since consumers have long been content with USB 2.0, and since<br />

SuperSpeed devices will initially be more expensive, consumers<br />

will need to be convinced of compelling application benefi ts before<br />

it is likely to see broad adoption. Streaming multimedia is almost<br />

undoubtedly the killer app that will make this happen.<br />

One of the major things holding back USB 3.0 is the lack of support<br />

for it in core logic chipsets. Intel made much of its support for the<br />

standard at IDF 2009, and there was plenty of talk about it at the<br />

USB pavilion. However, at IDF 2010 Intel made no production silicon<br />

announcements—reportedly because of the diffi culty of developing<br />

bug-free silicon—and there does not appear to be any plan to include<br />

it in either Sandy Bridge or Atom processors for the next year or so.<br />

Intel’s apparent hesitation about supporting the standard will clearly<br />

stall its adoption in the marketplace and give Intel-based embedded<br />

developers pause about including it in their designs. Despite its recent<br />

hesitation, Intel will almost undoubtedly support USB 3.0 by next year.<br />

Meanwhile, the USB-IF announced more than 100 SuperSpeedcertifi<br />

ed products at IDF 2010, so this train, while still getting up<br />

to speed, has clearly left the station. It is now up to embedded<br />

developers to determine whether USB 3.0 is appropriate for their<br />

applications, and if so, to get on board.<br />

66


Digi-Key, at your service.<br />

Programming<br />

Programmable Oscillators<br />

Digi-Reel<br />

Battery Packs<br />

Cable Assembly Services<br />

Departments<br />

Phone ....................................................................800-344-4539<br />

Sales/General Inquiries ..........................................E-mail: sales@digikey.com<br />

Phone: 218-681-6674<br />

Fax: 218-681-3380<br />

Customer Service ..................................................E-mail: customer.service@digikey.com<br />

Technical Support ..................................................E-mail: techs@digikey.com<br />

Design Support Services (DSS) ...............................E-mail: design@digikey.com<br />

Phone: 877-DK-DESIGN (877-353-3744)<br />

Quote Request ........................................................E-mail: quotes@digikey.com<br />

Comments/Suggestions .........................................E-mail: webmaster@digikey.com<br />

Web Links:<br />

Feedback ...............................................................www.digikey.ca/feedback<br />

My Digi-Key ...........................................................www.digikey.ca/registration<br />

<strong>TechZone</strong>s SM ..........................................................www.digikey.ca/techzones<br />

PTM Online...On Demand ® .....................................www.digikey.ca/ptm<br />

New@Digi-Key ......................................................www.digikey.ca/new<br />

DK Toolbar .............................................................www.digikey.ca/toolbar<br />

BOM Manager ........................................................www.digikey.ca/bommanager<br />

Digi-Key Catalogue ................................................www.digikey.ca/catalogue<br />

Technical Support Web Chat ..................................www.digikey.ca/techchat<br />

2


Digi-Key’s <strong>TechZone</strong>s SM<br />

• Featured products from<br />

leading suppliers<br />

• Application notes,<br />

references designs,<br />

PTMs, exclusive editorial<br />

• Parametric search<br />

tools and more!<br />

Text Paper Contains 10% Post-Consumer Fiber<br />

Please Recycle<br />

©<strong>2011</strong> Digi-Key Corporation, 701 Brooks Ave. South, Thief River Falls, MN 56701, USA<br />

www.digikey.ca/techzones

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!