The S08 is Freescale’s (now NXP’s) current 8-bit microcontroller family. It is a minor update of the HC08 family, which was a major update of the HC05. Freescale retained binary (object) code backwards compatibility – that is, the HC05 instruction set is a strict subset of the HC08, and the HC08 is a strict subset of the S08 – but because the memory map and peripheral blocks have fundamentally changed during these evolutions, it’s unlikely that any actual HC05 binary code would run on an HC08, let alone an S08.
The HC08 improves upon the HC05 in the following ways:
- the Stack Pointer (SP) is 16-bits wide, so the stack can be anywhere in RAM, and can be bigger than 64 bytes (the maximum size on the HC05)
- an 8-bit H register was added, which, concatenated with the 8-bit X register, can be used as a 16-bit pointer anywhere in the memory map; however, while a 16-bit offset can be used with X, this is not as efficient or flexible as having a true 16-bit pointer register
- a handful of instructions (LDHX, STHX, CPHX, PSHH, PULH) were added to make using HX easier
- an overflow (V) bit was added to the condition code register (bringing the HC08 closer to the 6800, 6809, and 68HC11; the 6805 had dropped the V bit)
- signed branch instructions (BLT, BGE, BLE, BGT) – which require a V bit – were added
The S08 adds the following to the HC08:
- pipelined CPU
- background debug mode (BDM) – a single-wire non-intrusive debug connection
- built-in on-chip debug resources (watchpoint, breakpoint)
- a new BGND instruction (halts CPU and enters debug mode)
- new addressing modes for a few instructions (LDHX, STHX, CPHX) to improve stack efficiency
- improved peripherals
- sophisticated and flexible clock generation
- two voltage range families: 3 V (1.8 to 3.6 V), and 5 V (2.7 to 5.5 V)
The pipelined CPU, while it can take one more bus clock than the HC08 for some instructions, can be run much faster. The HC08 tops out at 8 MHz, while many S08 variants can run at 20 MHz, and a few run at 25 MHz.
Background debug mode (BDM) replaces the HC08’s ROM bootloader, which implemented a quirky and inefficient bit-banged serial interface. BDM is much faster, and can be used to inspect memory and I/O registers even while the CPU core is running. It’s much more like something you’d see on a 32-bit microcontroller – but it’s built-in to every S08, even one that only costs $0.50.
Since this means that S08 chips ship from the factory totally blank, some kind of bootrapping process is necessary to get code onto them.
The clock generators are really cool. Take, for example, the ICS (internal clock source), the clock generation block found on most newer S08 subfamilies. It combines an external oscillator (to drive an external crystal or resonator), an internal oscillator (trimmable within 0.2% from 31.25 kHz to 39.0625 kHz), and an FLL (frequency-locked loop) with a divider that can be used to multiply either the internal or external oscillator up to 40 MHz.
Mode switching is done completely in software, so the configuration is very flexible. At power-on-reset (POR), the internal oscillator and FLL are configured for a bus clock of 4 MHz (nominally). Nine bits of trim can be stored in flash and written to the ICS at reset to set the frequency very accurately. I’ve successfully used the trim to set a bus clock of 9.216 MHz, which is an integral multiple of 115,200. The ICS clock is stable and accurate enough to drive a UART without a crystal!
The S08 is a superior family in every respect. No new design should be based on the HC08! Use the S08 instead.
References
For the full story, read the S08 family reference manual. Freescale’s book Understanding small microcontrollers is a tutorial introduction to their HC05 microcontroller family. Since the HC05 is a predecessor (ancestor?) of the S08 and shares much of the instruction set with it, much of that book would be relevant to the S08.
Suggested subfamilies for experimentors
I have some “favorite” S08 parts. There are many subfamilies, some designed for very specific uses. But there are also good general-purpose parts. Here is a short list of my favorites. Several of these are available in DIP, but, unfortunately for hobbyists, the S08 mostly comes in surface-mount packages.
S08QG
This is the first S08 part I got working. I ordered a few samples of the S08QG8 in a DIP 16 package, along with a few 908QB8s. I ended up using the 908s to “bootstrap” the QG8s, via the background debug mode (BDM) pin on the QG.
I was initially interested in using one, way back in 2006, for my Spoken Word project. (I never built that, but I’d still like to.)
The chips have some curious errata; the most serious one involves the internal clock source (ICS), and prevents it from running full-bore (at 10 MHz). Freescale suggest running the chip at 5 MHz instead, which is perhaps fine for that application, but in general is a bit disappointing. The DIP packaged S08QEs are probably better choices. They are a tiny bit more expensive than their QG cousins, but also have more features; in particular, they have more timer channels.
A few features:
- 1.8v to 3.6v operation
- Trimmable internal clock source, accurate enough for UART use without a crystal
- 10 MHz max bus clock
- 4 KiB or 8 KiB of flash memory, 256 or 512 bytes RAM
- 8 and 16 pin packages (DIP, SOIC, and TSSOP)
- SCI, SPI, and I2C interfaces
- 16-bit timer with capture, compare, and PWM
S08QE
This comes in the same flavours as the QG (DIP 16, 4 KiB and 8 KiB flash) but also in larger packages with more flash and RAM – up to 128 KiB flash.
It is closely related to the S08QG but has a few more features (and fewer silicon errata!). Like the QG, the QE parts have an operating range of 1.8V to 3.6V.
If you are looking for a versatile, inexpensive, general-purpose 8-bit microcontroller, and are sold on the S08 architecture, this should be your go-to part.
The S08QE32 in SOIC 28 is a really nice sweet spot. They cost around $2, are easy to prototype (with dipmicro’s proto boards, or other SOIC “breakout” boards), have 12 timer channels and two UARTs, and run at 25 MHz.
The S08QE is really three sub-subfamilies:
QE4 and QE8
- DIP 16, TSSOP 16, SOIC 20, SOIC 28, LQFP 32, and QFN 32 packages
- 10 MHz max bus clock
- 4 KiB or 8 KiB of flash
- 256 or 512 bytes of RAM
- One SCI (uart), one SPI, and one I2C
- Two 3-channel 16-bit timers; only 4 channels pinned out on 16-pin devices
- 10-channel ADC (10-bit on 16- and 20-pin parts; 12-bit on others)
QE16 and QE32
- SOIC 28, LQFP 32, QFN 32, LQFP 44, and QFN 48 packages
- 25 MHz max bus clock
- 16 KiB or 32 KiB of flash
- 1 KiB or 2 KiB of RAM
- Two SCIs (uarts), one SPI, and one I2C
- One 6-channel and two 3-channel timers (!!); all 12 channels pinned out on 28-pin device
- 10-channel 12-bit ADC
QE64, QE96, and QE128
- LQFP 32, LQPF 44, QFN 48, LQFP 64, and LQFP 80 packages
- 25 MHz max bus clock
- 64 KiB, 96 KiB, or 128 KiB of flash
- 4 KiB, 6 KiB, or 8 KiB of RAM
- Two SCIs (uarts), two SPIs, and two I2Cs (one on 44- and 48-pin packages)
- One 6-channel and two 3-channel timers (!!)
- 24-channel 12-bit ADC (!!) (only 10-channel on 44- and 48-pin devices)
S08JS
This is an interesting chip. Unlike most other S08s, which must be programmed by external means using BDM, the JS has a USB bootloader in ROM, making it very easy to prototype with. (See my instructions for building a JS16 USB board.) It’s also very cheap – $1.50 or so in unit quantity – but unfortunately only comes in an SOIC package, so it’s not quite as approachable as a Microchip PIC USB part in a DIP. But it’s not too bad. I’m not great with a soldering iron, but I was able to put together two JS16 boards in a few hours, and both worked the first time (the ROM bootloader successfully enumerated over USB).
Features:
- 8 KiB or 16 KiB of flash memory
- full-speed USB interface
- USB bootloader in ROM
- easy-to-prototype SOIC 16 package
- ridiculous price: $1.44, quantity one
This part is a great way to get started with the S08 family. It’s easy and cheap to build a JS16 USB board and use it to explore the S08 architecture.
I’ve used my JS16 board to program and debug both S08 and AVR parts. It’s really useful!
S08JM
This is a sort of “upgrade” of the S08JS, even though it came first. It’s like a cross between the S08QE and the S08JS: USB interface, a good selection of timers, UARTs, etc, and up to 60 KiB of flash. Unlike the S08JS, it has no ROM bootloader, so it must be programmed over BDM. And it only comes in LQFP packages.
I had big dreams of making an Arduino killer using this part, but now that dirt-cheap 48 MHz ARM Cortex-M0+ parts have arrived, that time has largely past.
This is still a really cool device. If you want a USB-capable, versatile, inexpensive, general-purpose 8-bit microcontroller, and are sold on the S08 architecture, the S08JM is a great choice. You have to be able and willing to deal with LQFP packages, however. It’s a bit disappointing that these chips aren’t available in more “approachable” packages. The Microchip PIC really wins in this regard. There are several PIC18 and PIC24 variants with built-in USB that come in DIP packages.
It wasn’t until Freescale introduced the S08JS subfamily in a friendlier-for-prototyping SOIC package that I jumped onto the USB bandwagon. I built a JS16 USB board that has for some time been my connection to all things microcontroller. Since the S08JM has a similar memory map and an identical USB interface, it should be trivial to get my USB code working on an S08JM – if I could make a board. (Actually, dipmicro now sell an LQFP 44 0.8mm pitch breakout board that would be perfect for this.)
The S08JM is really two sub-subfamilies:
JM8 and JM16
- LQFP 32, LQFP 44, and QFN 48 packages
- 24 MHz max bus clock
- 8/1 KiB or 16/1 KiB of Flash/RAM
- 256 bytes of dedicated USB RAM
- full-speed (12 Mbit) USB device interface with six uni-directional endpoints (in addition to bi-directional Endpoint 0)
- Two SCI interfaces (uarts) (one on 32-pin devices)
- Two SPI interfaces (one on 32-pin devices)
- One I2C interface
- One 2-channel and one 4-channel 16-bit timer (only 4 channels pinned out on 32-pin device)
- 8-channel 12-bit ADC (4-channel on 32-pin devices)
JM32 and JM60
- LQFP 44, QFN 48, LQFP 64, and QFP 64 packages
- 24 MHz max bus clock
- 32/2 KiB or 60/4 KiB of Flash/RAM
- 256 bytes of dedicated USB RAM
- full-speed (12 Mbit) USB device interface with six uni-directional endpoints (in addition to bi-directional Endpoint 0)
- Two SCI interfaces (uarts)
- Two SPI interfaces
- One I2C interface
- One 2-channel and one 4-channel 16-bit timer (2nd timer has 6 channels on 64-pin devices)
- 8-channel 12-bit ADC (12-channel on 64-pin devices)