STM32 More Than a Core
Total Page:16
File Type:pdf, Size:1020Kb
2804003-Cantrell.qxp 3/7/2008 10:45 AM Page 80 SILICON UPDATE by Tom Cantrell More Than a Core While examining 32-bit microcontrollers last month, Tom decided that the STMicroelectronics STM32 was worth a second look. With the new ARM Cortex M3 core, good peripherals, integration, and energy efficiency, this could be just the MCU for your next project. Having covered the territory last debates have become less relevant, thought these shining stars would month (“More Bits, Less Filling,” especially for blue-collar embedded burn out so fast? Circuit Cellar 212, 2008), it’s not my apps. Maybe it’s just battle fatigue, The microprocessor was barely born intention to get stuck on the topic of having seen so many architectures before it headed into battle. Early 8-bit 32-bit MCUs. Believe me, there’s march off to war. Remember way back skirmishes foreshadowed the epic plenty of other neat stuff going on in the mainframe years (1960–1970s) struggle between the Intel ’x86 and with FPGAs, wireless, sensors, and when companies like Univac, the then Motorola 68K, a battle that other wonders of the silicon age. Burroughs, and Honeywell challenged counted a myriad of upstart architec- Nevertheless, if you have anything to IBM with “better” architectures? All tures as collateral casualties. May the do with embedded systems, you need dead and gone. 88K, i860, Clipper, 29K, and all of the to stay up to speed with the latest hot Then there were the fabulous mini- others rest in peace. rod chips or you’ll get left behind. computers such as the Data General True believers are entitled to pitch In some ways these fast and furious Nova and the Digital Equipment VAX. their favorite architecture and poo-poo MCUs remind me of the brand new Like teenagers, they seemed invinci- the others. Taking nothing away from Tesla Motors high-performance elec- ble. “Nova” indeed. Who would have Cortex M3, the fact is that all of the tric vehicle just now hitting the streets. It’s got the efficiency and ICode green aspects of a golf cart, but can Flash interface Flash smoke the tires when you punch it. DCode memory Cortex-M3 The big difference is that the 32-bit System MCUs don’t cost an arm and a leg, but in fact are a luxury any designer SRAM can afford. DMA So this month, you’re invited to Ch. 1 AHB system bus Bridge 1 look over my shoulder as I pop the Ch. 2 Bridge 2 APB2 APB1 hood on the STMicroelectronics STM32 (see Figure 1). You’ll recall Ch. 7 GPIOA USART1 USART2 WWDG GPIOB SPI1 USART3 CAN from last time that its main claim to GPIOC ADC1 SPI2 BKP fame is the use of the new ARM GPIOD ADC2 I2C1 PWR GPIOE TIM1 I2C2 TIM2 Cortex M3 core. Sure, that’s newswor- EXTI AFIO USB TIM3 thy, but there’s more to the STM32 IWDG TIM4 than that. WORLD BEYOND CORE DMA Request Indeed, over the years, I’ve come to Figure 1—The ARM Cortex M3 core is the attention-getter in the new STM32 MCU from STMicroelectronics. But the conclusion that “core wars” there’s more to an MCU than a processor core, including lots of flash memory, fast SRAM, and a bunch of I/O. 80 Issue 213 April 2008 CIRCUIT CELLAR® www.circuitcellar.com 2804003-Cantrell.qxp 3/7/2008 10:45 AM Page 81 Package pins 36 36 48 48 48 64 64 64 100 100 Flash 32 KB 64 KB 32 KB 64 KB 128 KB 32 KB 64 KB 128 KB 64 KB 128 KB SRAM 10 (6) KB 20 (10) KB 10 (6) KB 20 (10) KB 20 (16) KB 10 (6) KB 20 (10) KB 20 (16) KB 20 (10) KB 20 (16) KB General-purpose 2 3 2 3 3 2 3 3 3 3 timers Advanced control 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) timer SPI 1 1 1 2 2 1 2 2 2 2 I2C 1 1 1 2 2 1 2 2 2 2 USART 2 2 2 3 3 2 3 3 3 3 Full-speed USB 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 2.0 CAN 2.0B 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 1 (0) 12-bit 1-µs A/D 2 (1) × 10 ch 2 (1) × 10 ch 2 (1) × 10 ch 2 (1) × 10 ch 2 (1) × 10 ch 2 (1) × 16 ch 2 (1) × 16 ch 2 (1) × 16 ch 2 (1) × 16 ch 2 (1) × 16 ch General-purpose 26 26 37 37 37 51 51 51 80 80 I/Os CPU Frequency 72 (36) MHz 72 (36) MHz 72 (36) MHz 72 (36) MHz 72 (36) MHz 72 (36) MHz 72 (36) MHz 72 (36) MHz 72 (36) MHz 72 (36) MHz Table 1—STMicroelectronics blasts off the starting line with a full complement of 20 STM32 parts, divided equally between “Performance” and “Access” lines. In this table, the “Access” line features are shown in parenthesis where they differ from the “Performance” line. Another difference is that both lines come standard with a –40° to 85°C tempera- ture range, but the “Performance” parts also have an extended temperature range (–40° to 105°C) option. major 32-bit MCUs (including the can lead to the awkward situation a curse if the I/O traffic clogs available ARM7 and ARM9 chips ST also offers) where more “megahertz” means less bus bandwidth and demands a lot of are fully capable of getting the job performance. It’s no surprise that handholding by the processor. The done in most applications. most 32-bit MCUs devote silicon to STM32 avoids that pitfall with multi- Look at a die photo of any 32-bit the cause of getting around the flash ple on-chip I/O busses to boost band- flash MCU and what you’ll find is a bottleneck. The STM32 is no excep- width and a powerful seven-channel little processor core stuck in the cor- tion, using a 64-bit wide flash bus in DMA controller that offloads the ner, dwarfed by surrounding memory conjunction with two 64-bit prefetch processor of I/O grunt work. and I/O silicon. The fact is, while the buffers to hide the flash latency. Even Another way to boost bus band- architecture chosen for the core may though this simple prefetch scheme is width is to demand less of it in the be the sizzle, it’s the implementation relatively unobtrusive, there may be first place. As I went through the of an entire chip that’s the steak. times when you’d prefer to turn it off, specs, I was impressed with the way which the STM32 allows you to do. the STM32 uses “smart” I/O devices FLASH FOR CASH If you really need max MIPS, take that take care of their own dirty laun- Sure architecture has an impact on advantage of the fact that the STM32 dry rather than bugging the processor performance, but so do a lot of other allows execution of code from the on- to do it for them. things starting with bus bandwidth. chip SRAM at full speed. You can use Even the simple stuff such as serial The differences (relatively minor actu- the SRAM as a “programmer directed and parallel I/O is pretty fancy these ally) in the way competing architec- cache,” preloading it with perform- days. Every STM32 I/O line is indi- tures choose to deal with instructions ance-critical routines such as DSP vidually programmable as input (pull- and data don’t matter nearly as much inner loops and interrupt handlers. up and pull-down options) or output as how fast a particular chip can actu- Just remember that a MIPS rating is (push/pull or open collector with out- ally do it. only half the story. You can crank put drive strength options). I/O lines In the blue-collar space these chips through all of the instructions you are also 5-V tolerant and can target, we’re generally talking about non- want, but nothing useful happens source/sink a whopping 25 mA, with cache implementations. That means flash until data makes its way to and from the not unexpected caveat that total (i.e., instruction fetch) bandwidth is a crit- the pins. As a practical matter, the on- chip power is limited to 150 mA. A ical limiting factor. The STM32 comes in chip I/O devices are just as important measure of port-remapping capability two flavors, “Access” and “Performance,” as the processor core itself in achiev- enables juggling peripheral pin with a major difference being that the for- ing peak system performance. assignments to best fit a particular mer runs up to 36 MHz and the latter to application. 72 MHz (see Table 1). Just keep in mind I/O U As I’ve noted before, the traditional that higher clock rates require 0, 1, or 2 I/O throughput starts with the num- RISC load/store architecture is prob- flash wait states for clock rates up to ber and performance of the on-chip I/O lematic for “atomic” bit operations 24, 48, and 72 MHz, respectively. devices themselves. The STM32 has a because an interrupt might occur If something isn’t done, wait states lot of fast I/O, but that can actually be between the load and the store.