The Renesas RL78 for Low-Power Applications

Renesas Technology announced in late March he start of a design challenge for engineers around the world: develop an innovative, low-power application using the RL78 MCU and IAR Systems toolchain. To get started, you need to familiarize yourself with the RL78. Clemens Valens, Editor-in-Chief of Elektor online, introduces the RL78 in a comprehensive “The RL78 Microcontroller: An MCU Family for Low-Power Applications” (Circuit Cellar 261, 2012).

I’ve worked with Valens in various occasions, and had the pleasure of meeting him in 2011. He’s truly “an engineer’s engineer”: extremely embedded tech savvy, well-read, and inquisitive. Furthermore, I edited Circuit Cellar articles Valens wrote about diverse design projects, such as a virtual instrument interface and a scrolling LED message board. Thus, it’s clear to me that Valens understands the importance of designing high-quality, energy-efficient, systems—and doing so within budget. I trust you’ll find his introduction to the RL78 insightful and immediately applicable.

The RL78 Microcontroller: An MCU Family for Low-Power Applications

By Clemens Valens (Circuit Cellar 261, 2012)

The low-power 8/16-bit microcontroller (MCU) market is a bit of a warzone with several MCU manufacturers proposing “the industry’s lowest power solution.” In a YouTube video, Texas Instruments boasts a best active figure of 160 μA/MIPS for their MSP430 family. In application note AN1267, Microchip Technology claims 110 μA at “1 MHz Run” for their PIC16LF72X. And Renesas Electronics announced 70 μA at “1-MHz normal operation” on their RL78 product website.[1, 2, 3] The absence of justification on how exactly these figures were obtained makes comparing them rather useless. But then again, you don’t really have to because, as most low-power developers know from experience, if you don’t get the hardware and software design right, you will never attain the promised 20-year battery lifetime no matter how low the MCU’s active, sleep, or standby current may be. In this article, I will take a closer look at Renesas’s quickly expanding RL78 family to see what they offer that may help you create a low-power design.

Photo 1 - The Renesas RL78

THE RL78 FAMILY

The RL78 family of 16-bit MCUs currently has two branches, “generic” and “application specific,” but a third “display” branch is forthcoming. The generic branch contains the subfamilies G12, G13, and G1A, all based on the 78K core, and the G14, which is based on the R8C core. In the application-specific branch there is the 1A and F12. I am not sure about their core origins as these products are still very new and, at the time of writing, documentation is missing. It doesn’t really matter; from now on it is the new RL78 core for all. Since they share the same core, I will concentrate on the G13 for which I have a nice evaluation board (see Photo 1 and “The Renesas Demonstration Kit for RL78” sidebar).

Sidebar: Renesas Demonstration Kit

RL78/G13

This family comes in a large number of variants (I counted 182), with devices having from 20 up to 128 pins (see Figure 1). Note that the parts themselves are labelled R5F10xx. The differences between all these variants are, besides the package type, the amounts of flash memory (program and data) and RAM. Program flash memory starts at 16 KB and currently ends at 512 KB, data flash sizes can be 0, 4, or 8 KB and RAM is 2 KB for the small devices and up to 32 KB for the big ones.

Figure 1 - Diagram of 128-pin RL78/G13 devices

The CPU is 16-bit, but the internal memory architecture is 8 bit. Its 32 general-purpose registers are organized in four banks of eight and can be used as 8- or 16-bit registers. The memory-mapped special function registers (SFRs) that control the on-chip peripherals can be addressed per bit, per byte, or as 16-bit registers, depending on the register. A second set of SFRs, the extended or second SFRs, are available too, but they need longer instructions to be accessed.

For those who need to squeeze the maximum out of MCU performance, it may be interesting to know that the CPU offers a short addressing mode enabling you to access a page of 256 bytes with a minimum amount of code.

The maximum clock frequency of the processor is 32 MHz, but the hardware user’s manual, which is almost 1,100 pages, interestingly also boasts about the ultra-low-speed capabilities of the processor as it can run from a 32.768-kHz clock.

The RL78 core features 15 I/O ports, most of which are 8-bit wide. Port 13 is 2-bit wide and ports 10 and 15 are 7-bit wide. The port pins that are actually available depend on the device. Inputs and outputs are highly configurable. Inputs can be analog, CMOS, or TTL. Outputs can be CMOS or N-channel open drain. Pull-up resistors are available too. The exact configuration possibilities depend on the port pin, so consult the datasheet. Because of the many configuration options, it is possible to use the MCU in multi-voltage systems without level-shifting circuitry except for the occasional external pull-up resistor. The chip can be powered from 1.6 V to 5.5 V, the core itself runs from 1.8 V provided by an internal voltage regulator.

TIME MANAGEMENT

Several options are available for the MCU clock. When clock precision is not too important, the MCU can be run from its internal clock, up to 32 MHz, otherwise it is possible to connect an external crystal, resonator, or oscillator. An internal low-speed clock (15 kHz) is also available, but not for the CPU, only for the watchdog timer (WDT), the real-time clock (RTC), and the interval timer.

The timers of the RL78 are flexible and offer many functions. Depending on the pin size of the device, you can have up to 16 16-bit timers, grouped in two arrays of eight. Each timer (called a “channel”) can function as an interval timer, square-wave generator, event counter, frequency divider, pulse-interval timer, pulse-duration timer, and delay counter. For even more possibilities, timers can be combined to create monostable multivibrators or to do pulse-width modulation (PWM). This way, up to seven PWM signals can be generated from one master timer. If you need more timers but resolution is less important, you can split some 16-bit timers in two 8-bit timers (this is not possible with all timers). Timer 7 of array 0 is extra special as it features local interconnect network (LIN) network support (see below).

Aside from date and time keeping with alarms, the RTC also provides constant period interrupts at 2 Hz and 1 Hz and also every minute, hour, day, or month. A 1-Hz output is available on devices with 40 or more pins. For extra precision, the RTC offers a correction register for fine tuning the 32,768-kHz clock. Unsurprisingly, the RTC continues operation when the MCU is stopped.

Now that I mentioned Stop mode, a special interval timer peripheral enables wakeup from this mode at periodic intervals. This timer is also used for the analog-to-digital converter’s (ADC’s) Snooze mode. More on that later. With a clock frequency of 32,768 Hz, the lowest interval rate is 8 Hz (0.125 ms).

Yet another time-related peripheral on the RL78 is the buzzer controller (not available on 20-pin devices). This is a clock output destined at IR comms carrier generation, to clock other chips in a system or to produce sound from a buzzer. A gate bit enables modulation of this output in such a way that pulses always have the same width.

Finally, a WDT completes the timing peripherals. It has a special Window mode that limits the time frame during which you can reset the watchdog to a fraction of the watchdog interval (50%, 75%, or 100%). Resetting the watchdog counter outside the window results in a reset. The window is open in the second part of the interval. An interrupt can be generated when the WDT reaches 75% of its time-out value, (i.e., when the watchdog reset window is known to be open in all cases). Figure 2 illustrates the mechanism.

Figure 2 - Trying to reset the watchdog counter when the window is closed results in an internal reset signal

ADC

The ADC is of the 10-bit successive approximation type and can have up to 26 inputs. Several triggering options are provided, hardware and software, where hardware triggering means triggering by a timer module (timer channel 1 end of count or capture, interval timer, or RTC). The time it takes to do a conversion depends partly on the triggering mode. When input stabilization is not too much of an issue (i.e., when you don’t switch inputs) you can achieve conversion times of just over 2 μs.

Two registers enable comparing the ADC’s output to maximum and minimum values, producing an interrupt when the new value is either in or out of bounds. This function is also available in Snooze mode. In this mode, the processor itself is stopped and consumes very little power, but ADC conversions continue under control of the hardware trigger. When a conversion triggers an ADC interrupt, the processor can then wake up from Snooze mode and resume normal operation.

COMMUNICATIONS

The RL78 features multifunction serial units. The devices with 25 pins or less have one such unit, the others have two. Only serial unit 2 provides LIN bus support.

A serial unit can function in asynchronous UART mode, in synchronous CSI mode (three-wire bus with clock, data in and data out signals, master and slave mode supported), and in simplified (master-only) I²C mode. Again, depending on the device, you can have up to four UARTs or eight CSI and/or simplified I²C ports. Of course a mix is also possible. Full I²C is possible with the specialized I²C unit.

UART0 and UART2, CSI00 and CSI20 provide Snooze mode functionality similar to the ADC. In Snooze mode, these ports can be made to wake up on the arrival of incoming data without waking up the CPU. If the received data is interesting enough, it is also possible to wake up the CPU.

LIN communications are possible with UART2 together with Timer 7 of Array 0. The LIN bus is an inexpensive alternative to the CAN bus in automotive systems to control simple devices like switches, sensors, and actuators. LIN only uses one wire and is rather low speed (20 Kbps maximum). The timer takes care of the LIN synchronization issues and the UART performs the (de)serialisation of the data.

Full blown I²C communication is possible with the specialized I²C peripheral IICA. The 80-pin and more devices have two channels, the others only one. Communication speeds up to 20 MHz are permitted to enable I²C “fast mode” (3.5 MHz) and “fast mode plus” (10 MHz). This module is capable of waking up the CPU from Stop mode.

MATH ACCELERATORS

Of interest is the hardware multiplier and divider module intended for filtering and FFT functions. This module is capable of 16 × 16 bits signed and unsigned multiplications and divisions producing 32-bit results. It can also do 16 × 16 bit multiply-accumulate. We are talking about a module here, not an instruction, meaning that you have to load the operands yourself in special registers and get the result from yet another. The multiplication itself is done in one clock cycle, a division takes 16. The accumulate operation adds another cycle.

Another special math function is the binary-coded decimals (BCD) correction register that enables you to easily transform binary calculation results into BCD results.

DIRECT MEMORY ACCESS

To speed up data transport without loading the CPU, the RL78 core features direct memory access (DMA), up to four channels. DMA transfers up to 1,024 words of data (8 or 16 bit) to and from SFRs and RAM and they can be started by a range of interrupts (e.g., ADC, serial, timer). Although DMA transfers are done in parallel with normal CPU operation, it does slow down the CPU. For time-critical situations, it is possible to put a DMA transfer on hold for a number of clock cycles and let the CPU finish its job first.

INTERRUPTS

Interrupts are pretty standard on the RL78 and many sources are available. The “key interrupt” function on the other hand is less common. It provides up to eight (depending on the device, you guessed it) key or push button inputs that are ORed together to generate an interrupt on a key press (active low).

OPERATING MODES & SECURITY

Besides the aforementioned Stop and Snooze modes, the RL78 also provides a Halt mode. In this mode, the CPU is stopped but the clocks keep running, making a fast resume possible. In Stop mode, the clocks are stopped too reducing power consumption more than in Halt mode. Snooze mode is like Stop mode, but with one or more peripherals in a snoozing state, ready to wake up when something interesting happens. Interrupts can be used to wake up from Snooze, Stop, or Halt mode. A reset usually works too.

Reset, by the way, can have seven origins, three of which are related to safety functions: illegal instruction, RAM parity, and illegal memory access. Two others involve the power supply: power-on reset (POR) and low-voltage detection (LVD). All these reset options are needed to conform to the International Electrotechnical Commission (IEC) 60730-1 (“Automatic Electrical Controls for Household and Similar Use; Part 1: General Requirements”) and IEC 61508-SER (“Functional Safety of Electrical/Electronic/Programmable Electronic Safety-Related Systems”) safety standards. Since the RL78 is compliant, it also implements flash memory CRC checking, protections to prevent RAM and SFRs to be modified when the CPU stops functioning, an oscillator frequency-detection circuit, and an ADC self-test function.

The hardware used for the flash memory CRC check is also available as a general-purpose CRC module for user programs. It implements the standard CCITT CRC-16 polynomial (X^16 + X^12 + X^5 + 1).

The RAM guard function protects only up to 512 bytes, so be careful where you put your sensitive data.

FLASH & FUSES

Those familiar with the fuse bytes of PIC and AVR processors will be happy to know that the RL78 contains four of them, the option bytes that configure such things as the WDT, low-voltage detection, flash memory modes, clock frequencies, and debugging modes.

Flash memory is divided into two parts, program memory and data memory, and it can be programmed in-circuit over a serial interface. A boot partition is available too. This partition uses a kind of ping-pong mechanism called “boot swapping” to ensure that a valid bootloader is always programmed into the boot partition so that even power failures during bootloader programming will not harm the boot partition. A flash window function protects the memory against unintentionally reprogramming parts of it.

SOUNDING OFF

This concludes our voyage through the Renesas RL78 core. As you have seen, the RL78 offers many interesting peripherals all combined in a flexible low-power optimized design. Thanks to the integrated oscillator and other functions, an RL78 MCU can be used with very little external hardware, enabling inexpensive and compact designs. Once you master its Snooze mode and your low-power design skills, you can use this MCU family in battery-operated metering applications, for instance, but I am sure you can think of something more surprising.

Clemens Valens (c.valens@elektor.fr) is Editor-in-Chief of Elektor Online. He has more than 15 years of experience in embedded systems design. Clemens is currently interested in sound synthesis techniques, rapid prototyping, and the popularization of technology.

REFERENCES

[1] Texas Instruments, Inc., “Ultra-Low Power MSP430 – The World’s Lowest Power MCU,” 201.

[2] Microchip Technology, Inc., “AN1267: nanoWatt and nanoWatt XLP Technologies: An Introduction to Microchip’s Low-Power Devices,” 2009.

[3] Renesas Electronics Corp., “RL78 Family,” www.renesas.com/pr/mcu/rl78/index.html.

RESOURCES

International Electrotechnical Commission (IEC), “60730-1, Automatic Electrical Controls for Household and Similar Use; Part 1: General Requirements,” 2002.

———, “61508-SER, Functional Safety of Electrical/

Electronic/Programmable Electronic Safety-Related Systems,” 2010.

Renesas Electronics Corp., Renesas Rulz, “RL78/G13 Demonstration Kit,” www.renesasrulz.com/community/demoboards/rdkrl78g13.

For more information about the RL78 Family of microcontrollers, visit www.renesas.com.

For information about the 2012 Renesas RL78 Green Energy Challenge (in association with Elektor & Circuit Cellar), go to www.circuitcellar.com/RenesasRL78Challenge.

This article appears in Circuit Cellar 261 (April 2012).

 

 

Weekly Elektor Wrap Up: Preamplifier 2012, Pico C, & a Webshop Hunt

It’s time for our Friday Elektor wrap up. Our Elektor colleagues were hard at work during this first week of April. Here’s quick review.

Elektor Preamplifier 2012: The Sound of Silence

Elektor has a 40-year history of high-end audio (tube and solid state) coverage: projects, books, circuit boards, and even DVDs. The latest project is the Preamplifier 2012, which was designed by renowned audio specialist Douglas Self, with Elektor audio staffer Ton Giesberts doing the board designs and testing on Elektor’s $50,000 audio precision analyzer! It achieves incredibly low noise figures using low impedance design techniques throughout, but still based on an affordable and easy-to-find opamp: the NE5532. The Preamplifier 2012’s most notable characteristics are its ultra low noise MC/MD section (get out your vinyl records) and the remarkably low-value pots in the Baxandall tone control (like 1-kΩ).Douglas Self and Elektor Audio Labs already stunned the audio community with their NE5532 Op-amplifier a while ago with 32 NE5532 op-amps basically paralleled on a board producing 10 W of extremely high-quality sound. Simply put: they know what they’re doing!You can read about the seven-board design in the April 2012 edition. In fact, why not follow the series?

Part 1: www.elektor.com/110650

Part 2: www.elektor.com/110651

Part 3: currently in editing for June 2012 edition.

NE5532 Opamplifier: www.elektor.com/100124

Pico C Webinar Announcement

Elektor announced this week that it will run a new webinar via element14 on the Elektor Pico C meter, which was featured in the April 2011 editions. The Pico C meter can measure small capacitances. In February 2012 the device was upgraded with new firmware.

According to an Elektor news item, UK-based author/designer Jon Drury will run the webinar slated for Thursday, April 19, 2012. He’ll cover a unique way of giving the original instrument a much wider range while also extending its functionality, all with new software and practically no changes to the existing Pico C hardware. Microcontroller fans, including AVR enthusiasts, can also learn how to adapt the software for different calibration capacitors. Elektor staffers are reporting that Jon may also give a sneak preview of his PicoLO oscilloscope and Pico DDS generator.  You can register at element14.

“E” Hunt!

In other news, Elektor is challenging you to find hidden Easter eggs in its webshop. Find eggs, get a discount. Click here to get started.

 

 

Tech Highlights from Design West: RL78, AndroPod, Stellaris, mbed, & more

The Embedded Systems Conference has always been a top venue for studying, discussing, and handling the embedded industry’s newest leading-edge technologies. This year in San Jose, CA, I walked the floor looking for the tech Circuit Cellar and Elektor members would love to get their hands on and implement in novel projects. Here I review some of the hundreds of interesting products and systems at Design West 2012.

RENESAS

Renesas launched the RL78 Design Challenge at Design West. The following novel RL78 applications were particularly intriguing.

  • An RL78 L12 MCU powered by a lemon:

    A lemon powers the RL78 (Photo: Circuit Cellar)

  • An RL78 kit used for motor control:

    The RL78 used for motor control (Photo: Circuit Cellar)

  • An RL78 demo for home control applications:

    The RL78 used for home control (Photo: Circuit Cellar)

TEXAS INSTRUMENTS

Circuit Cellar members have used TI products in countless applications. Below are two interesting TI Cortex-based designs

A Cortex-M3 digital guitar (you can see the Android connection):

TI's digital guitar (Photo: Circuit Cellar)

Stellaris fans will be happy to see the Stellaris ARM Cortex -M4F in a small wireless application:

The Stellaris goes wireless (Photo: Circuit Cellar)

NXP mbed

Due to the success of the recent NXP mbed Design Challenge, I stopped at the mbed station to see what exciting technologies our NXP friends were exhibiting. They didn’t disappoint. Check out the mbed-based slingshot developed for playing Angry Birds!

mbed-Based sligshot for going after "Angry Birds" (Photo: Circuit Cellar)

Below is a video of the project on the mbedmicro YouTube page:

FTDI

I was pleased to see the Elektor AndroPod hard at work at the FTDI booth. The design enables users to easily control a robotic arm with Android smartphones and tablets.

FTDI demonstrates robot control with Android (Photo: Circuit Cellar)

As you can imagine, the possible applications are endless.

The AndroPod at work! (Photo: Circuit Cellar)

FPGA-Based VisualSonic Design Project

The VisualSonic Studio project on display at Design West last week was as innovative as it was fun to watch in operation. The design—which included an Altera DE2-115 FPGA development kit and a Terasic 5-megapixel CMOS Sensor (D5M)—used interactive tokens to control computer-generated music.

at Design West 2012 in San Jose, CA (Photo: Circuit Cellar)

I spoke with Allen Houng, Strategic Marketing Manager for Terasic, about the project developed by students from National Taiwan University. He described the overall design, and let me see the Altera kit and Terasic sensor installation.

A view of the kit and sensor (Photo: Circuit Cellar)

Houng also he also showed me the design in action. To operate the sound system, you simply move the tokens to create the sound effects of your choosing. Below is a video of the project in operation (Source: Terasic’s YouTube channel).

Issue 261: The Deeply Embedded 8-Bit MCU

The 8 bit debate continues. Last week at Design West in San Jose, CA, the topic came up more than once, and I reported on Microchip Technology’s expanded 8-bit PIC16F(LF)178X midrange core MCU family.

Over the years, Circuit Cellar has published several articles on the topic. Back in Circuit Cellar 8 (1989) Tom Cantrell tackled the topic in an article titled “HD647180X: A New 8-Bit Microcontroller Embedded Controllers Get Respect.” In 2010 in Circuit Cellar 143 he tackled the topic again in an article titled “Live for Today: The 8-Bit MCU Still Matters.” This month in an editorial titled “8-Bit Control Is Dead – No Way!” (Circuit Cellar 261), Steve Ciarcia weighs in on the long-debated topic.

For years tech pundits have been predicting the end of 8-bit micros. Apparently, with the prices of 16- and 32-bit MCUs constantly dropping, and presuming you always want your application to do more stuff, there is no reason not to replace a less powerful MCU, right? In my opinion, it was a false assumption then, and it still is today.

We can’t look at this as a zero-sum game. Yes, 32-bitters open up all kinds of new opportunities for embedded processing, especially in the area of network-connected personal entertainment and information devices. But this doesn’t mean they’re a better fit in the low-end control and text-based applications that the 8-bitters have occupied for so long. The boundaries are certainly “fuzzy,” but consider how we tend to generally categorize MCUs.

At the low end, we have the 8-bit controllers which typically have 8-bit data and registers along with 16-bit address paths. This is a sweet spot for all kinds of control and text-based functions that simply don’t need to handle more than 64 KB of data at a time. The price/performance of the 8-bit chip should win this fight every time.

In the midrange, we have the 16-bit MCUs and lower-end 16-bit DSP chips. These chips can do a bunch more because they handle 16-bit data and have at least 24-bit address paths. There is often a hardware multiplier as well, which makes this class of chip ideal for many types of signal processing and audio applications.

At the high end, there is the 32-bit MCU/MPU (and higher-end DSPs) that have 32-bit data and address paths. These are the chips that have the power to drive an interactive graphical user interface and process video signals in real time.

It’s clear that chip manufacturers believe in the future of all three classes of MCU; just look at the innovations they continue to introduce at all levels. Fundamentally, as the silicon improves in terms of transistor density, more memory fits onto a smaller chip, and there’s more room for on-chip peripherals. Also, clock and power management has become a lot more flexible than ever before. The lower-end and midrange MCUs are all available with some combination of hardware timers (e.g., PWM, pulse capture, and motor control), communications (e.g., UART, SPI, I2C, CAN, USB, etc.), and analog interface (e.g., ADC, DAC, and touch). Some include hardware controllers for multiplexed LCDs or Ethernet interfaces.

At the higher end, in addition to all of that, we also see options like on-chip SDRAM controllers, SD memory and I/O controllers, Ethernet MAC (and sometimes PHY), mass storage (ATAPI, SATA) and video support, including in some cases a separate GPU core. Basically, everything you need to run a full-up operating system like Windows, MacOS, or Android.

Probably the greatest result of across-the-board lower MCU costs is that we will be seeing multiple chips where just one was used before. This has been the situation with automobiles for years where reliability has increased with lots of “smart”-control modules all networked together. Certainly, this make senses in a $30,000 car, but the concept is moving down the cost spectrum as well. Take your typical household washing machine or dryer that has a motor or two and a control panel. Instead of one chip handling all of the control functions and user interface I/O, there will be one (or two) motor controller chip with a communications interface (e.g, SPI, I2C, CAN, etc.) and a second chip with a communications interface along with an LCD controller and touch sensor support.

If the system designers are forward-thinking when they define the protocol by which these subsystems communicate, they’ll end up with intelligent building blocks (e.g., “smart motor,” “smart valve,” “smart sensor”) that can be easily reused in other products, keeping manufacturing costs low. The modules themselves will be reliable and energy-efficient, contributing substantially to end-user satisfaction and low recurring costs. The key is to make each module just smart enough without going overboard on processing power or overloading it with a top-heavy protocol.

And, that’s where the lowly 8-bit MCU shines. A smart valve that just needs to sit on a LIN or 1-wire bus, operate a solenoid, and verify that it opened or closed doesn’t need a lot of CPU cycles or 32-bit addressing to do the job. One of the tiny 8-bitters in a six- or eight-pin package will do nicely, and might even cost less than the manufacturing cost and testing of the dedicated wiring harness needed to do the job in the traditional way. There’s no way a 16-bit or 32-bit MCU makes sense in this context. But more importantly, these lowly control tasks aren’t going to go away. In fact, I think you’ll be seeing a lot more of them and they’ll all need MCUs. So, although it will be less visible, the 8-bit MCU will still be deeply embedded in increasingly subtle, but important, parts of your life, working hard so you don’t have to.